Skip to content

Commit 01624ac

Browse files
authored
Merge pull request #79 from codecrafters-io/repo-aware-caching-rust
Use repository-aware caching for Rust
2 parents 16298f7 + aa81da5 commit 01624ac

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

dockerfiles/rust-1.77.Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1+
# syntax=docker/dockerfile:1.7-labs
12
FROM rust:1.77-buster
23

3-
COPY Cargo.toml /app/Cargo.toml
4-
COPY Cargo.lock /app/Cargo.lock
4+
WORKDIR /app
55

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

9-
WORKDIR /app
109
RUN cargo build --release --target-dir=/tmp/codecrafters-http-server-target
11-
1210
RUN cargo clean -p http-server-starter-rust --release --target-dir=/tmp/codecrafters-http-server-target
1311

14-
RUN rm -rf /app/src
15-
1612
RUN echo "cd \${CODECRAFTERS_SUBMISSION_DIR} && cargo build --release --target-dir=/tmp/codecrafters-http-server-target --manifest-path Cargo.toml" > /codecrafters-precompile.sh
1713
RUN chmod +x /codecrafters-precompile.sh
1814

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

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

0 commit comments

Comments
 (0)