diff --git a/dockerfiles/go-1.19.Dockerfile b/dockerfiles/go-1.19.Dockerfile index 09964b6..7327b3c 100644 --- a/dockerfiles/go-1.19.Dockerfile +++ b/dockerfiles/go-1.19.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM golang:1.19-alpine RUN apk add --no-cache 'curl>=7.66' @@ -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 diff --git a/dockerfiles/go-1.21.Dockerfile b/dockerfiles/go-1.21.Dockerfile index 27ed6da..0ddbbbe 100644 --- a/dockerfiles/go-1.21.Dockerfile +++ b/dockerfiles/go-1.21.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM golang:1.21-alpine RUN apk add --no-cache 'curl>=7.66' @@ -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 diff --git a/dockerfiles/go-1.22.Dockerfile b/dockerfiles/go-1.22.Dockerfile index 141ab9d..f09e7fd 100644 --- a/dockerfiles/go-1.22.Dockerfile +++ b/dockerfiles/go-1.22.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM golang:1.22-alpine RUN apk add --no-cache 'curl>=7.66' @@ -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 diff --git a/dockerfiles/rust-1.43.Dockerfile b/dockerfiles/rust-1.43.Dockerfile index 2031ff4..72d120e 100644 --- a/dockerfiles/rust-1.43.Dockerfile +++ b/dockerfiles/rust-1.43.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.43-buster # Download docker-explorer @@ -5,17 +6,19 @@ 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" \ No newline at end of file +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" +# Once the heave steps are done, we can copy all files back +COPY . /app diff --git a/dockerfiles/rust-1.54.Dockerfile b/dockerfiles/rust-1.54.Dockerfile index fd70f0f..386db52 100644 --- a/dockerfiles/rust-1.54.Dockerfile +++ b/dockerfiles/rust-1.54.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.54-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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" \ No newline at end of file +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" +# Once the heave steps are done, we can copy all files back +COPY . /app diff --git a/dockerfiles/rust-1.62.Dockerfile b/dockerfiles/rust-1.62.Dockerfile index 6a93ce3..3d783fb 100644 --- a/dockerfiles/rust-1.62.Dockerfile +++ b/dockerfiles/rust-1.62.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.62-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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 diff --git a/dockerfiles/rust-1.68.Dockerfile b/dockerfiles/rust-1.68.Dockerfile index 7af11cc..2fd1867 100644 --- a/dockerfiles/rust-1.68.Dockerfile +++ b/dockerfiles/rust-1.68.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.68-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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 diff --git a/dockerfiles/rust-1.70.Dockerfile b/dockerfiles/rust-1.70.Dockerfile index 103d0d3..bb0b39c 100644 --- a/dockerfiles/rust-1.70.Dockerfile +++ b/dockerfiles/rust-1.70.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.70-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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 diff --git a/dockerfiles/rust-1.76.Dockerfile b/dockerfiles/rust-1.76.Dockerfile index 2b9a65e..7e0c501 100644 --- a/dockerfiles/rust-1.76.Dockerfile +++ b/dockerfiles/rust-1.76.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.76-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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 diff --git a/dockerfiles/rust-1.77.Dockerfile b/dockerfiles/rust-1.77.Dockerfile index 5d54b28..05fe95e 100644 --- a/dockerfiles/rust-1.77.Dockerfile +++ b/dockerfiles/rust-1.77.Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7-labs FROM rust:1.77-buster # Download docker-explorer @@ -5,13 +6,13 @@ 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 @@ -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