Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: use cache mount for npm install #10835

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
set -eo pipefail

# disable cache mounts as github cache is slow
find -name Dockerfile -print0 | xargs -0 sed -Ei 's/--mount=type=cache,target=[^[:blank:]]+//g'
find -name Dockerfile -o -name "Dockerfile.*" -print0 | xargs -0 sed -Ei 's/--mount=type=cache,target=[^[:blank:]]+//g'

TRANSIENT_FAILURES=(
"failed to solve: failed to compute cache key"
Expand Down
3 changes: 2 additions & 1 deletion front/docker/Dockerfile.playwright
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM mcr.microsoft.com/playwright:$PLAYWRIGHT_VERSION

COPY front/package.json front/package-lock.json /app/front/
WORKDIR /app/front
RUN npm install --frozen-lockfile
RUN --mount=type=cache,target=/root/.npm \
npm install --frozen-lockfile

COPY front /app/front/
COPY tests /app/tests
Expand Down
5 changes: 3 additions & 2 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ ENV VITE_OSRD_GIT_DESCRIBE=${OSRD_GIT_DESCRIBE}
COPY --from=front_src package.json package-lock.json /app/

# If SKIP_FRONT is set to 1, skip the front build
RUN if [ "$SKIP_FRONT" = "1" ]; then exit 0; else npm ci; fi
RUN --mount=type=cache,target=/root/.npm \
if [ "$SKIP_FRONT" = "1" ]; then exit 0; else npm ci; fi

# Generate the licenses file and build
COPY --from=front_src . /app
ENV NODE_OPTIONS="--max_old_space_size=4096"
RUN if [ "$SKIP_FRONT" = "1" ]; then \
RUN if [ "$SKIP_FRONT" = "1" ]; then \
mkdir -p build; \
echo '<html><body><h1>No front, as this image was built for running it in dev mode</h1></body></html>' > build/index.html; \
else \
Expand Down
Loading