-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docker): cache packages to speed up builds
- Loading branch information
1 parent
6736ba1
commit 369640c
Showing
1 changed file
with
22 additions
and
5 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,10 +1,27 @@ | ||
FROM rust:1.82.0-bullseye as builder | ||
ENV APP atBB | ||
WORKDIR /usr/src/$APP | ||
FROM rust:1.82.0-bullseye as base | ||
RUN cargo install sccache --version ^0.7 | ||
RUN cargo install cargo-chef --version ^0.1 | ||
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache | ||
|
||
FROM base AS planner | ||
WORKDIR /app | ||
COPY . . | ||
RUN cargo install --path . | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo chef cook --release --recipe-path recipe.json | ||
COPY . . | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \ | ||
cargo install --path . | ||
|
||
FROM debian:bullseye-slim | ||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* | ||
COPY --from=builder /usr/local/cargo/bin/$APP /usr/local/bin/$APP | ||
COPY --from=builder /usr/local/cargo/bin/atBB /usr/local/bin/atBB | ||
ENTRYPOINT [ "/usr/local/bin/atBB" ] |