Skip to content

Commit

Permalink
ci: Move libvalhalla into a separate cache layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Kizim committed Oct 14, 2024
1 parent fa54479 commit 141fb7b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ WORKDIR /usr/src/app
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo 'fn main() { println!("Dummy image called!"); }' > src/main.rs
# And for every other target in the workspace
RUN mkdir -p libvalhalla/src && echo '' > libvalhalla/src/lib.rs
COPY libvalhalla/Cargo.toml ./libvalhalla/
RUN mkdir -p libvalhalla/src && touch libvalhalla/src/lib.rs
RUN cargo build --release

# libvalhalla compilation takes a lot, worth to move it into a separate cache layer
COPY libvalhalla ./libvalhalla
RUN touch -a -m ./libvalhalla/src/lib.rs
RUN cargo build --release

# Now build the real target
COPY src ./src
COPY libvalhalla ./libvalhalla
# Update modified attribute as otherwise cargo won't rebuild it
RUN touch -a -m ./src/main.rs
RUN touch -a -m ./libvalhalla/src/lib.rs
RUN cargo build --release

FROM debian:bookworm-slim AS runner
Expand Down

0 comments on commit 141fb7b

Please sign in to comment.