From 32ef612b0a7f60d404de81bf1d20fee079a30789 Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Sat, 22 Jun 2024 18:40:30 -0300 Subject: [PATCH] fix: Improve Docker layer caching on frontend changes Avoid any changes in the `frontend/` folder to trigger `npm install`. Instead, split the copies to have separate steps for install and build. --- docker/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 81d53758c..2f7c4842e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,12 @@ # Build frontend FROM node:lts-alpine as front-build-stage WORKDIR /front + +COPY ./frontend/package*.json ./ +RUN npm ci + COPY ./frontend ./ -RUN npm install && npm run build +RUN npm run build # Setup frontend and backend FROM nginx:1.27.0-alpine3.19-slim as production-stage