Skip to content

Commit

Permalink
Add cargo-chef to speed up docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiezzel committed Nov 6, 2023
1 parent 9244011 commit 32454f5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,28 @@ COPY --from=archive-router-builder /archive-router/target/release/router ./route
ENTRYPOINT ["/archive-router/router"]
EXPOSE 3000

FROM --platform=$BUILDPLATFORM rust:1.70-bookworm AS network-builder
FROM --platform=$BUILDPLATFORM lukemathwalker/cargo-chef:latest-rust-bookworm AS chef
WORKDIR /app

FROM --platform=$BUILDPLATFORM chef AS network-planner

COPY Cargo.toml .
COPY Cargo.lock .
COPY crates ./crates

COPY subsquid-network/Cargo.toml ./subsquid-network/
COPY subsquid-network/Cargo.lock ./subsquid-network/
COPY subsquid-network/transport ./subsquid-network/transport

RUN cargo chef prepare --recipe-path recipe.json

FROM --platform=$BUILDPLATFORM chef AS network-builder

RUN apt update
RUN apt install -y -V protobuf-compiler

WORKDIR /usr/src
COPY --from=network-planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY Cargo.toml .
COPY Cargo.lock .
Expand All @@ -36,8 +52,8 @@ RUN apt-get update && apt-get install ca-certificates net-tools -y

WORKDIR /run

COPY --from=network-builder /usr/src/target/release/network-scheduler /usr/local/bin/network-scheduler
COPY --from=network-builder /usr/src/crates/network-scheduler/config.yml .
COPY --from=network-builder /app/target/release/network-scheduler /usr/local/bin/network-scheduler
COPY --from=network-builder /app/crates/network-scheduler/config.yml .

ENV P2P_LISTEN_ADDR="/ip4/0.0.0.0/tcp/12345"
ENV HTTP_LISTEN_ADDR="0.0.0.0:8000"
Expand All @@ -55,8 +71,8 @@ RUN apt-get update && apt-get install ca-certificates net-tools -y

WORKDIR /run

COPY --from=network-builder /usr/src/target/release/query-gateway /usr/local/bin/query-gateway
COPY --from=network-builder /usr/src/crates/query-gateway/config.yml .
COPY --from=network-builder /app/target/release/query-gateway /usr/local/bin/query-gateway
COPY --from=network-builder /app/crates/query-gateway/config.yml .

ENV P2P_LISTEN_ADDR="/ip4/0.0.0.0/tcp/12345"
ENV HTTP_LISTEN_ADDR="0.0.0.0:8000"
Expand Down

0 comments on commit 32454f5

Please sign in to comment.