Install npm deps in separate docker layer

This commit is contained in:
Hugh Nimmo-Smith 2023-01-11 18:55:28 +00:00
parent a565d2a7d3
commit 6fa73ec214
2 changed files with 14 additions and 4 deletions

View File

@ -1,9 +1,14 @@
FROM docker.io/node:alpine as builder
RUN apk add --no-cache git python3 build-base
COPY . /app
WORKDIR /app
RUN yarn install \
&& yarn build
# Copy package.json and yarn.lock and install dependencies first to speed up subsequent builds
COPY package.json yarn.lock /app/
RUN yarn install
COPY . /app
RUN yarn build
FROM docker.io/nginx:alpine
COPY --from=builder /app/target /usr/share/nginx/html

View File

@ -1,7 +1,12 @@
FROM docker.io/node:alpine
RUN apk add --no-cache git python3 build-base
COPY . /code
WORKDIR /code
# Copy package.json and yarn.lock and install dependencies first to speed up subsequent builds
COPY package.json yarn.lock /code/
RUN yarn install
COPY . /code
EXPOSE 3000
ENTRYPOINT ["yarn", "start"]