-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (49 loc) · 1.65 KB
/
Dockerfile
File metadata and controls
64 lines (49 loc) · 1.65 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
63
64
# DGate API Gateway - Multi-stage Dockerfile
# Build stage for Rust compilation
FROM rust:1.92-bookworm AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libclang-dev \
cmake \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests first for better caching
COPY Cargo.toml Cargo.lock ./
# Create dummy source files to build dependencies
RUN mkdir -p src/bin && \
echo "" > src/lib.rs && \
echo "fn main() {}" > src/main.rs && \
echo "fn main() {}" > src/bin/dgate-cli.rs && \
cargo build --release --bin dgate-server --bin dgate-cli && \
rm -rf src
# Copy actual source code
COPY src/ src/
# Build the actual binaries (touch to invalidate the dummy build cache)
RUN touch src/main.rs src/bin/dgate-cli.rs && \
cargo build --release --bin dgate-server --bin dgate-cli
# Runtime stage - minimal image
FROM debian:bookworm-slim AS runtime
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -r -s /bin/false dgate
WORKDIR /app
# Copy binaries from builder
COPY --from=builder /app/target/release/dgate-server /usr/local/bin/
COPY --from=builder /app/target/release/dgate-cli /usr/local/bin/
# Create data directory
RUN mkdir -p /app/data && chown dgate:dgate /app/data
# Switch to non-root user
USER dgate
# Expose ports (proxy, admin)
EXPOSE 80 443 9080
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD dgate-cli health || exit 1
# Default command
ENTRYPOINT ["dgate-server"]
CMD ["-c", "/app/config.yaml"]