Skip to content

Commit

Permalink
CC-1333 Add repository aware caching
Browse files Browse the repository at this point in the history
  • Loading branch information
libmartinito committed Jun 28, 2024
1 parent d751ce7 commit 13b2f88
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion dockerfiles/go-1.19.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.19-alpine

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

WORKDIR /app

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

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

Check failure on line 11 in dockerfiles/go-1.19.Dockerfile

View workflow job for this annotation

GitHub Actions / test_course_definition / docker_lint

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check


# Once the heave steps are done, we can copy all files back
COPY . /app
9 changes: 6 additions & 3 deletions dockerfiles/python-3.11.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# syntax=docker/dockerfile:1.7-labs
FROM python:3.11-alpine

RUN pip install pipenv

Check failure on line 4 in dockerfiles/python-3.11.Dockerfile

View workflow job for this annotation

GitHub Actions / test_course_definition / docker_lint

DL3013 warning: Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`

Check failure on line 4 in dockerfiles/python-3.11.Dockerfile

View workflow job for this annotation

GitHub Actions / test_course_definition / docker_lint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

COPY Pipfile /app/Pipfile
COPY Pipfile.lock /app/Pipfile.lock

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

ENV WORKON_HOME=/venvs

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

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock"
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock"
# Once the heave steps are done, we can copy all files back
COPY . /app
8 changes: 6 additions & 2 deletions dockerfiles/rust-1.70.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.70-buster

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

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

WORKDIR /app
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /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 +19,6 @@ RUN chmod +x /codecrafters-precompile.sh

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


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

0 comments on commit 13b2f88

Please sign in to comment.