mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
refactor: Dockerfile only copy package*.json before installing dependencies
This patch reorders some commands in `Dockerfile` to save time on building the docker image. The main goal is to only copy `package.json` and `package-lock.json` into the docker environment before installing dependencies via npm. Therefore, if the dependencies do not change (but other files may change), `docker build` will automatically use cached layers in previous build, instead of re-downloading the same set of dependencies again. This could save build time, especially during development at local machine. Furthermore, use `npm ci` instead of `npm i` can speed up the build process in CI environment. However, I notice that `package.json` and `package-lock.json` are out of sync now. So, `npm i` remains in `Dockerfile` as fallback for now. Once the two json files are in sync, this fallback can be removed.
This commit is contained in:
parent
3561d6e899
commit
33bacc37fa
1 changed files with 9 additions and 8 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -3,19 +3,20 @@
|
|||
### build ###
|
||||
|
||||
# base image
|
||||
FROM --platform=$BUILDPLATFORM node:20 as build
|
||||
|
||||
# add app
|
||||
COPY . /app
|
||||
FROM --platform=$BUILDPLATFORM node:20 AS build
|
||||
|
||||
# set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# add `/app/node_modules/.bin` to $PATH
|
||||
ENV PATH /app/node_modules/.bin:$PATH
|
||||
# install dependencies
|
||||
COPY package*.json /app
|
||||
RUN (npm ci || npm i) && npm i -g @angular/cli
|
||||
|
||||
RUN npm i
|
||||
RUN npm i -g @angular/cli
|
||||
# add `/app/node_modules/.bin` to $PATH
|
||||
ENV PATH=/app/node_modules/.bin:$PATH
|
||||
|
||||
# add app
|
||||
COPY . /app
|
||||
|
||||
# run linter
|
||||
RUN npm run lint
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue