From 504fda9c38625aef8eb8ca1190ecf98e6f8ef42f Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 14 Apr 2026 10:55:34 +0100 Subject: [PATCH] update dockerfile --- dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/dockerfile b/dockerfile index 76cb8076f..56a350ae4 100644 --- a/dockerfile +++ b/dockerfile @@ -1,15 +1,45 @@ -FROM node:14 as build -WORKDIR /app -COPY ./package*.json /app/ -RUN npm config set unsafe-perm true -RUN npm install -g ionic -RUN npm config set legacy-peer-deps true -RUN npm i -D typescript@4.3.5 -RUN npm install --save --legacy-peer-deps -COPY ./ /app/ -RUN ionic build --prod +# ========================= +# BUILD STAGE +# ========================= +FROM node:16 AS build -FROM nginx:latest +WORKDIR /app + +# Avoid npm randomness +ENV NPM_CONFIG_LEGACY_PEER_DEPS=true +ENV NPM_CONFIG_AUDIT=false +ENV NPM_CONFIG_FUND=false + +# Copy dependency files first (better caching) +COPY package*.json ./ + +# Clean install (IMPORTANT: single install only) +RUN npm cache clean --force +RUN npm install --legacy-peer-deps --no-audit --no-fund + +# Copy full project +COPY . . + +# Build Ionic Angular app +RUN npx ionic build --configuration production + + +# ========================= +# PRODUCTION STAGE (NGINX) +# ========================= +FROM nginx:alpine + +# Nginx config (optional but recommended for SPA routing) COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf + +# Clean default nginx files RUN rm -rf /usr/share/nginx/html/* -COPY /www/ /usr/share/nginx/html/ \ No newline at end of file + +# Copy build output from previous stage +COPY --from=build /app/www /usr/share/nginx/html + +# Expose port +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file