From dc7335c4efe6b6a051b0d16a89ac6db5a609ef6e Mon Sep 17 00:00:00 2001 From: Frank Niessink Date: Tue, 5 Nov 2024 18:08:08 +0100 Subject: [PATCH] Use multi-stage build for frontend container. --- components/frontend/Dockerfile | 20 ++++++++++++-------- components/renderer/Dockerfile | 3 +-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/components/frontend/Dockerfile b/components/frontend/Dockerfile index 7290f96d7e..d5ad26969b 100644 --- a/components/frontend/Dockerfile +++ b/components/frontend/Dockerfile @@ -1,18 +1,22 @@ +FROM node:23.1.0-alpine3.20 AS compile-image + +WORKDIR /home/frontend +COPY public /home/frontend/public +COPY package*.json /home/frontend +COPY src /home/frontend/src +COPY .env /home/frontend +RUN npm install --ignore-scripts && \ + npm run --ignore-scripts build + FROM node:23.1.0-alpine3.20 LABEL maintainer="Quality-time team " LABEL description="Quality-time frontend" WORKDIR /home/frontend -COPY package*.json /home/frontend -COPY public /home/frontend/public -COPY src /home/frontend/src COPY healthcheck.js /home/frontend -COPY .env /home/frontend -RUN npm install --ignore-scripts -g npm@10.9.0 && \ - npm install --ignore-scripts && \ - npm install --ignore-scripts -g serve@14.2.4 && \ - npm run --ignore-scripts build && \ +COPY --from=compile-image /home/frontend/build /home/frontend/build +RUN npm install --ignore-scripts -g serve@14.2.4 && \ adduser frontend --disabled-password USER frontend diff --git a/components/renderer/Dockerfile b/components/renderer/Dockerfile index 41628fac8a..83d9ce45e3 100644 --- a/components/renderer/Dockerfile +++ b/components/renderer/Dockerfile @@ -15,8 +15,7 @@ RUN apk add --no-cache \ chromium=130.0.6723.116-r0 && \ rm -rf /var/cache/apk/* /tmp/* && \ update-ms-fonts && \ - fc-cache -f && \ - npm install --ignore-scripts -g npm@10.9.0 + fc-cache -f WORKDIR /home/renderer COPY package*.json /home/renderer/