-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Dockerfile): revert to chef based build
New build seems to have PATH issues.
- Loading branch information
Showing
1 changed file
with
28 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,37 @@ | ||
# This file is used to build the docker image for the server. | ||
# It makes sure to split the build into two stages: | ||
# 1. Build dependencies and cache them. | ||
# 2. Build the executable and copy it into a minimal runtime image. | ||
# For context on the approach see: | ||
# https://stackoverflow.com/questions/58473606/cache-rust-dependencies-with-docker-build | ||
|
||
FROM rust as builder | ||
FROM lukemathwalker/cargo-chef:latest-rust-latest AS chef | ||
WORKDIR /app | ||
|
||
# Build deps. We replace our main.rs with a dummy.rs to avoid rebuilding the | ||
# main executable, creating a cached layer for the dependencies. | ||
COPY Cargo.toml Cargo.lock ./ | ||
RUN mkdir src/ | ||
RUN echo "fn main() {}" > dummy.rs | ||
RUN sed -i 's#src/bin/serve.rs#dummy.rs#' Cargo.toml | ||
RUN cargo build --release --bin serve | ||
FROM chef AS planner | ||
COPY . . | ||
# Figure out if dependencies have changed. | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
# Build executables. | ||
RUN sed -i 's#dummy.rs#src/bin/serve.rs#' Cargo.toml | ||
COPY src ./src | ||
COPY .sqlx ./.sqlx | ||
COPY migrations ./migrations | ||
RUN cargo build --release --bin phoenix-service | ||
RUN cargo build --release --bin record-eth-price | ||
RUN cargo build --release --bin sync-beacon-states | ||
RUN cargo build --release --bin sync-execution-blocks | ||
RUN cargo build --release --bin sync-execution-supply-deltas | ||
RUN cargo build --release --bin update-effective-balance-sum | ||
RUN cargo build --release --bin update-issuance-breakdown | ||
RUN cargo build --release --bin update-issuance-estimate | ||
RUN cargo build --release --bin update-supply-projection-inputs | ||
RUN cargo build --release --bin update-validator-rewards | ||
# serve changes the most, put it last. | ||
RUN cargo build --release --bin serve | ||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build dependencies - this layer is cached for massive speed up. | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
# Build application - this should be re-done every time we update our src. | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
# Build runtime image. | ||
FROM gcr.io/distroless/cc-debian12 AS runtime | ||
FROM debian:bullseye-slim AS runtime | ||
WORKDIR /app | ||
|
||
COPY --from=builder /app/target/release/phoenix-service /app | ||
COPY --from=builder /app/target/release/record-eth-price /app | ||
COPY --from=builder /app/target/release/serve /app | ||
COPY --from=builder /app/target/release/sync-beacon-states /app | ||
COPY --from=builder /app/target/release/sync-execution-blocks /app | ||
COPY --from=builder /app/target/release/sync-execution-supply-deltas /app | ||
COPY --from=builder /app/target/release/update-effective-balance-sum /app | ||
COPY --from=builder /app/target/release/update-issuance-breakdown /app | ||
COPY --from=builder /app/target/release/update-issuance-estimate /app | ||
# sqlx depends on native TLS, which is missing in buster-slim. | ||
RUN apt update && apt install -y libssl1.1 ca-certificates | ||
|
||
COPY --from=builder /app/target/release/phoenix-service /usr/local/bin | ||
COPY --from=builder /app/target/release/record-eth-price /usr/local/bin | ||
COPY --from=builder /app/target/release/serve /usr/local/bin | ||
COPY --from=builder /app/target/release/sync-beacon-states /usr/local/bin | ||
COPY --from=builder /app/target/release/sync-execution-blocks /usr/local/bin | ||
COPY --from=builder /app/target/release/sync-execution-supply-deltas /usr/local/bin | ||
COPY --from=builder /app/target/release/update-effective-balance-sum /usr/local/bin | ||
COPY --from=builder /app/target/release/update-issuance-breakdown /usr/local/bin | ||
COPY --from=builder /app/target/release/update-issuance-estimate /usr/local/bin | ||
COPY --from=builder /app/src/bin/update-supply-projection-inputs/in_contracts_by_day.json /app/src/bin/update-supply-projection-inputs/in_contracts_by_day.json | ||
COPY --from=builder /app/target/release/update-supply-projection-inputs /app | ||
COPY --from=builder /app/target/release/update-validator-rewards /app | ||
COPY --from=builder /app/target/release/update-supply-projection-inputs /usr/local/bin | ||
COPY --from=builder /app/target/release/update-validator-rewards /usr/local/bin | ||
|
||
EXPOSE 3002 | ||
ENTRYPOINT ["/app/serve"] | ||
ENTRYPOINT ["/usr/local/bin/serve"] |