Skip to content

Commit

Permalink
Use lockfiles from bind mount and drop extra COPY layer
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Jan 18, 2024
1 parent da2f966 commit 9a52eba
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ FROM node:21-slim as dependency-base
libpixman-1-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev \
&& apt-get clean -yqqq

COPY package*.json /app/

FROM dependency-base as build
# Install dependencies (with dev-deps)
RUN npm ci
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY . /app/
RUN npm run compile

FROM dependency-base as runtime-dependencies
RUN NODE_ENV=production npm ci
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
NODE_ENV=production npm ci

FROM node:21-slim
WORKDIR /app
Expand Down

0 comments on commit 9a52eba

Please sign in to comment.