Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (45 loc) · 1.32 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# ForgeCode Gateway Docker Image
# Multi-stage build for optimized production image
# Stage 1: Build stage
FROM rust:1.92-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy source code
COPY . .
# Build the gateway in release mode
RUN cargo build --release --package forge_gateway
# Stage 2: Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 forgecode
# Create app directory
WORKDIR /app
# Copy binary from builder stage
COPY --from=builder /app/target/release/forge_gateway /app/forge_gateway
# Copy static files
COPY --from=builder /app/crates/forge_gateway/static /app/static
# Set ownership
RUN chown -R forgecode:forgecode /app
# Switch to non-root user
USER forgecode
# Expose the gateway port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/api/health || exit 1
# Environment variables
ENV RUST_LOG=info
ENV FORGE_GATEWAY_PORT=8080
ENV FORGE_GATEWAY_BIND=0.0.0.0
# Start the gateway
CMD ["/app/forge_gateway"]