Merge pull request #983 from vector-im/hughns/docker-deps-layer

Install npm deps in separate docker layer
This commit is contained in:
Bruno Windels 2023-01-17 08:50:45 +00:00 committed by GitHub
commit 86ce54d69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -1,9 +1,14 @@
FROM docker.io/node:alpine as builder FROM docker.io/node:alpine as builder
RUN apk add --no-cache git python3 build-base RUN apk add --no-cache git python3 build-base
COPY . /app
WORKDIR /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 FROM docker.io/nginx:alpine

View File

@ -1,7 +1,12 @@
FROM docker.io/node:alpine FROM docker.io/node:alpine
RUN apk add --no-cache git python3 build-base RUN apk add --no-cache git python3 build-base
COPY . /code
WORKDIR /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 RUN yarn install
COPY . /code
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT ["yarn", "start"] ENTRYPOINT ["yarn", "start"]