Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #868 from abetterinternet/timg/smaller-docker-image
Browse files Browse the repository at this point in the history
facilitator: smaller container image
  • Loading branch information
tgeoghegan authored Aug 2, 2021
2 parents 35779a7 + 1ebc372 commit d1505ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions facilitator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.53.0-alpine as builder
FROM rust:1.54.0-alpine as builder

RUN apk add libc-dev openssl-dev && apk update

Expand All @@ -23,7 +23,7 @@ RUN sed -i /build.rs/d facilitator/Cargo.toml
RUN mkdir -p facilitator/src
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > facilitator/src/main.rs
# This cargo build command must match the one below, or the build cache will not be reused.
RUN cargo build --manifest-path ./facilitator/Cargo.toml
RUN cargo build --manifest-path ./facilitator/Cargo.toml --release

# Clean up and copy the real source.
# After this we have a layer that should be cacheable so long as the dependencies don't change.
Expand All @@ -38,10 +38,14 @@ ARG BUILD_INFO=unspecified
ENV OPENSSL_STATIC=true

# This cargo build command must match the one above, or the build cache will not be reused.
RUN cargo build --manifest-path ./facilitator/Cargo.toml
# We build in debug mode so the build runs quickly, then strip the binary for size.
RUN strip facilitator/target/debug/facilitator
RUN cargo build --manifest-path ./facilitator/Cargo.toml --release

# Build a minimal container from Alpine containing only the stripped binary and
# no intermediate build artifacts
FROM alpine:3.14

RUN apk add libgcc && apk update

# Build a minimal container containing only the binary, the one .so it needs, and root certs.
RUN cp /usr/src/prio-server/facilitator/target/debug/facilitator /facilitator
COPY --from=builder /usr/src/prio-server/facilitator/target/release/facilitator /facilitator
ENTRYPOINT ["/facilitator"]

0 comments on commit d1505ea

Please sign in to comment.