Skip to content

Commit 13b2f88

Browse files
committed
CC-1333 Add repository aware caching
1 parent d751ce7 commit 13b2f88

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

dockerfiles/go-1.19.Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# syntax=docker/dockerfile:1.7-labs
12
FROM golang:1.19-alpine
23

34
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum"
45

56
WORKDIR /app
67

7-
COPY go.mod go.sum ./
8+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
9+
COPY --exclude=.git --exclude=README.md . /app
810

911
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs -r go get
1012

13+
14+
# Once the heave steps are done, we can copy all files back
15+
COPY . /app

dockerfiles/python-3.11.Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# syntax=docker/dockerfile:1.7-labs
12
FROM python:3.11-alpine
23

34
RUN pip install pipenv
45

5-
COPY Pipfile /app/Pipfile
6-
COPY Pipfile.lock /app/Pipfile.lock
76

87
WORKDIR /app
8+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
9+
COPY --exclude=.git --exclude=README.md . /app
910

1011
ENV WORKON_HOME=/venvs
1112

@@ -14,4 +15,6 @@ RUN pipenv install
1415
# Force environment creation
1516
RUN pipenv run python3 -c "1+1"
1617

17-
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock"
18+
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock"
19+
# Once the heave steps are done, we can copy all files back
20+
COPY . /app

dockerfiles/rust-1.70.Dockerfile

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

3-
COPY Cargo.toml /app/Cargo.toml
4-
COPY Cargo.lock /app/Cargo.lock
54

65
RUN mkdir /app/src
76
RUN echo 'fn main() { println!("Hello World!"); }' > /app/src/main.rs
87

98
WORKDIR /app
9+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
10+
COPY --exclude=.git --exclude=README.md . /app
1011
RUN cargo build --release --target-dir=/tmp/codecrafters-grep-target
1112

1213
RUN cargo clean -p grep-starter-rust --release --target-dir=/tmp/codecrafters-grep-target
@@ -18,3 +19,6 @@ RUN chmod +x /codecrafters-precompile.sh
1819

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

22+
23+
# Once the heave steps are done, we can copy all files back
24+
COPY . /app

0 commit comments

Comments
 (0)