-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CC-1333 Add repository aware caching
- Loading branch information
1 parent
c2d1bbe
commit 911755b
Showing
14 changed files
with
84 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim | ||
|
||
COPY codecrafters-http-server.csproj /app/codecrafters-http-server.csproj | ||
COPY codecrafters-http-server.sln /app/codecrafters-http-server.sln | ||
|
||
RUN mkdir /app/src | ||
RUN (echo 'System.Console.WriteLine("If you are seeing this, there is something wrong with our caching mechanism! Please contact us at [email protected].");' > /app/src/Program.cs) > /dev/null | ||
|
||
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 | ||
|
||
# This saves nuget packages to ~/.nuget | ||
RUN dotnet build --configuration Release . | ||
|
@@ -22,3 +23,6 @@ RUN echo "cd \${CODECRAFTERS_SUBMISSION_DIR} && dotnet build --configuration Rel | |
RUN chmod +x /codecrafters-precompile.sh | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="codecrafters-http-server.csproj,codecrafters-http-server.sln" | ||
|
||
# Once the heave steps are done, we can copy all files back | ||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine | ||
|
||
COPY codecrafters-http-server.csproj /app/codecrafters-http-server.csproj | ||
COPY codecrafters-http-server.sln /app/codecrafters-http-server.sln | ||
|
||
RUN mkdir /app/src | ||
RUN (echo 'System.Console.WriteLine("If you are seeing this, there is something wrong with our caching mechanism! Please contact us at [email protected].");' > /app/src/Program.cs) > /dev/null | ||
|
||
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 | ||
|
||
# This saves nuget packages to ~/.nuget | ||
RUN dotnet build --configuration Release . | ||
|
@@ -22,3 +23,6 @@ RUN echo "cd \${CODECRAFTERS_SUBMISSION_DIR} && dotnet build --configuration Rel | |
RUN chmod +x /codecrafters-precompile.sh | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="codecrafters-http-server.csproj,codecrafters-http-server.sln" | ||
|
||
# Once the heave steps are done, we can copy all files back | ||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# 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 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM golang:1.21-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 | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM golang:1.22-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 | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM node:21.7-alpine3.19 | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,package-lock.json" | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
COPY package-lock.json ./ | ||
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses | ||
COPY --exclude=.git --exclude=README.md . /app | ||
|
||
# If dependencies in the package lock do not match those in package.json, instead of updating the package lock, npm ci will exit with an error. | ||
RUN npm ci | ||
|
||
RUN mkdir -p /app-cached | ||
# If the node_modules directory exists, move it to /app-cached | ||
RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi | ||
|
||
# Once the heave steps are done, we can copy all files back | ||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM ruby:3.3-alpine | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Gemfile,Gemfile.lock" | ||
WORKDIR /app | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install --verbose | ||
# .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 bundle install --verbose | ||
# Once the heave steps are done, we can copy all files back | ||
COPY . /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters