ci: utilize npm cache for faster docker builds

This commit is contained in:
Julian Tölle 2023-04-03 21:02:51 +02:00
parent f047b8180a
commit 54b04b814e

View file

@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1.5
FROM scratch as ignore FROM scratch as ignore
WORKDIR /listory WORKDIR /listory
@ -17,7 +19,9 @@ FROM common as build-api
LABEL stage="build-api" LABEL stage="build-api"
COPY *.json /app/ COPY *.json /app/
RUN npm ci RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci
COPY src/ /app/src/ COPY src/ /app/src/
RUN NODE_ENV=production npm run build RUN NODE_ENV=production npm run build
@ -33,7 +37,10 @@ ARG VERSION=unknown
WORKDIR /app/frontend WORKDIR /app/frontend
COPY frontend/package*.json /app/frontend/ COPY frontend/package*.json /app/frontend/
RUN npm ci RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci
COPY frontend/ /app/frontend/ COPY frontend/ /app/frontend/
RUN NODE_ENV=production npm run build RUN NODE_ENV=production npm run build
@ -55,7 +62,9 @@ WORKDIR /app
COPY package.json /app/ COPY package.json /app/
COPY package-lock.json /app/ COPY package-lock.json /app/
RUN npm ci --omit=dev RUN --mount=type=cache,target=/home/root/.npm \
npm set cache /usr/src/app/.npm && \
npm ci --omit=dev
COPY --from=build-api /app/dist/ /app/dist/ COPY --from=build-api /app/dist/ /app/dist/
COPY --from=build-frontend /app/frontend/build /app/static/ COPY --from=build-frontend /app/frontend/build /app/static/