Skip to content

Commit

Permalink
Add repository aware caching
Browse files Browse the repository at this point in the history
  • Loading branch information
libmartinito committed Jun 26, 2024
1 parent 72243e2 commit 37dfb46
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 19 deletions.
7 changes: 7 additions & 0 deletions dockerfiles/c-9.2.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# syntax=docker/dockerfile:1.7-labs
FROM n0madic/alpine-gcc:9.2.0

# .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 apk add --no-cache 'curl>=7.66'

# For making HTTP requests using libcurl
Expand All @@ -9,3 +13,6 @@ RUN apk add --no-cache --upgrade 'curl-dev>=7.66'
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 7 additions & 0 deletions dockerfiles/go-1.13.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.13-alpine

# .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 apk add --no-cache --upgrade 'curl>=7.66'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 7 additions & 0 deletions dockerfiles/go-1.16.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.16-alpine

# .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 apk add --no-cache --upgrade 'curl>=7.66'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 6 additions & 1 deletion dockerfiles/go-1.19.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.19-alpine

RUN apk add --no-cache 'curl>=7.66'
Expand All @@ -11,6 +12,10 @@ 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 ash -c "set -exo pipefail; go mod graph | awk '{if (\$1 !~ \"@\") {print \$2}}' | xargs -r go get"

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 6 additions & 1 deletion dockerfiles/go-1.21.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.21-alpine

RUN apk add --no-cache 'curl>=7.66'
Expand All @@ -11,10 +12,14 @@ 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

# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
RUN GODEBUG="installgoroot=all" go install std

RUN ash -c "set -exo pipefail; go mod graph | awk '{if (\$1 !~ \"@\") {print \$2}}' | xargs -r go get"

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 6 additions & 1 deletion dockerfiles/go-1.22.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22-alpine

RUN apk add --no-cache 'curl>=7.66'
Expand All @@ -11,10 +12,14 @@ 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

# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
RUN GODEBUG="installgoroot=all" go install std

RUN ash -c "set -exo pipefail; go mod graph | awk '{if (\$1 !~ \"@\") {print \$2}}' | xargs -r go get"

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 7 additions & 0 deletions dockerfiles/nim-1.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# syntax=docker/dockerfile:1.7-labs
FROM nimlang/nim:1.0.6-alpine

# .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 apk add --no-cache 'curl>=7.66'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

# Once the heave steps are done, we can copy all files back
COPY . /app
7 changes: 7 additions & 0 deletions dockerfiles/php-7.4.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# syntax=docker/dockerfile:1.7-labs
FROM php:7.4-cli-alpine

# .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 apk add --no-cache --upgrade 'curl>=7.66'
RUN apk add --no-cache --upgrade 'curl-dev>=7.66'

Expand All @@ -9,3 +13,6 @@ RUN docker-php-ext-install pcntl
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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

# .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 apk add --no-cache 'curl>=7.66'

# Download docker-explorer.
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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

# .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 apk add --no-cache 'curl>=7.66'

# Download docker-explorer.
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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

# .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 apk add --no-cache --upgrade 'curl>=7.66'
RUN apk add --no-cache --upgrade 'curl-dev>=7.66'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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

# .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 apk add --no-cache --upgrade 'curl>=7.66'
RUN apk add --no-cache --upgrade 'curl-dev>=7.66'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target

RUN rm -rf /app/src

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock"
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock"
# Once the heave steps are done, we can copy all files back
COPY . /app
9 changes: 6 additions & 3 deletions dockerfiles/rust-1.54.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.54-buster

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target
Expand All @@ -21,4 +22,6 @@ RUN rm -rf /app/src
RUN echo "cd \${CODECRAFTERS_SUBMISSION_DIR} && cargo build --release --target-dir=/tmp/codecrafters-docker-target --manifest-path Cargo.toml" > /codecrafters-precompile.sh
RUN chmod +x /codecrafters-precompile.sh

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

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target
Expand All @@ -23,3 +24,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
8 changes: 6 additions & 2 deletions dockerfiles/rust-1.68.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.68-buster

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target
Expand All @@ -23,3 +24,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
8 changes: 6 additions & 2 deletions dockerfiles/rust-1.70.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.70-buster

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target
Expand All @@ -23,3 +24,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
8 changes: 6 additions & 2 deletions dockerfiles/rust-1.76.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# syntax=docker/dockerfile:1.7-labs
FROM rust:1.76-buster

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

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-docker-target

RUN cargo clean -p docker-starter-rust --release --target-dir=/tmp/codecrafters-docker-target
Expand All @@ -23,3 +24,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
Loading

0 comments on commit 37dfb46

Please sign in to comment.