-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (56 loc) · 2.58 KB
/
Copy pathDockerfile
File metadata and controls
77 lines (56 loc) · 2.58 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
65
66
67
68
69
70
71
72
73
74
75
76
77
# Build stage
# For reproducible builds across machines, specify --platform:
# docker build --platform linux/amd64 ...
FROM rust:1.98.1-bookworm as base-builder
# Install protobuf compiler (pinned to upstream 3.21.12; the Debian
# packaging revision floats so point-release rebuilds don't break the build)
RUN apt-get update && apt-get install -y \
"protobuf-compiler=3.21.12-*" \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Set environment variables for reproducible builds
ENV SOURCE_DATE_EPOCH=0
ENV RUSTFLAGS="--remap-path-prefix /app=. --remap-path-prefix $HOME=~"
ARG GUARDIAN_SERVER_FEATURES=postgres
# Copy workspace manifests
COPY Cargo.toml Cargo.lock ./
COPY rust-toolchain.toml ./
COPY crates ./crates
COPY benchmarks ./benchmarks
COPY examples ./examples
# Build for release (only server)
FROM base-builder as server-builder
# build.rs reads this to stamp the git commit; the build context has no .git to fall back on.
ARG GUARDIAN_GIT_SHA
RUN if [ -n "$GUARDIAN_SERVER_FEATURES" ]; then \
cargo build --release --package guardian-server --bin server --bin ack-keygen --features "$GUARDIAN_SERVER_FEATURES"; \
else \
cargo build --release --package guardian-server --bin server --bin ack-keygen; \
fi
FROM base-builder as benchmark-builder
RUN cargo build --release --package guardian-prod-benchmarks --bin guardian-prod-benchmarks
# Runtime stage
FROM debian:bookworm-slim@sha256:7e490910eea2861b9664577a96b54ce68ea3e02ce7f51d89cb0103a6f9c386e0 as benchmark-runner
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=benchmark-builder /app/target/release/guardian-prod-benchmarks /app/guardian-prod-benchmarks
COPY --from=benchmark-builder /app/crates/contracts/masm /app/crates/contracts/masm
ENTRYPOINT ["/app/guardian-prod-benchmarks"]
# Runtime stage
FROM debian:bookworm-slim@sha256:7e490910eea2861b9664577a96b54ce68ea3e02ce7f51d89cb0103a6f9c386e0 as server-runner
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the server and the ACK identity generator from builder. ack-keygen lets a
# self-managed deployment mint its stable identity from the image alone:
# docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/ack-keys:/out" <image> /app/ack-keygen --out-dir /out
COPY --from=server-builder /app/target/release/server /app/server
COPY --from=server-builder /app/target/release/ack-keygen /app/ack-keygen
# Expose HTTP and gRPC ports
EXPOSE 3000 50051
CMD ["/app/server"]