Skip to content

Commit

Permalink
Use repository-aware caching for Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
glokta1 committed Jun 21, 2024
1 parent d9d1fb7 commit 065fb59
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dockerfiles/rust-1.77.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.77-buster

COPY Cargo.toml /app/Cargo.toml
COPY Cargo.lock /app/Cargo.lock
WORKDIR /app

RUN mkdir /app/src
RUN echo 'fn main() { println!("Hello World!"); }' > /app/src/main.rs
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

WORKDIR /app
RUN cargo build --release --target-dir=/tmp/codecrafters-grep-target

RUN cargo clean -p grep-starter-rust --release --target-dir=/tmp/codecrafters-grep-target
Expand All @@ -18,3 +17,5 @@ RUN chmod +x /codecrafters-precompile.sh

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock"

# Once the heavy steps are done, we can copy all files back
COPY . /app

0 comments on commit 065fb59

Please sign in to comment.