FROM node:18.19-alpine AS builder WORKDIR /app-builder COPY ./package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:1.25.1 WORKDIR /app ARG VERSION=next # NGINX redirect and cache control RUN sed -i '8 a \ \ \ \ \ \ \ \ try_files $uri $uri /index.html;' /etc/nginx/conf.d/default.conf # RUN sed -i "10 a \ \ \ \ \ \ \ \ location /env.js { add_header Cache-Control 'no-store'; add_header Cache-Control 'no-cache'; expires 0;}" /etc/nginx/conf.d/default.conf # https://pumpingco.de/blog/environment-variables-angular-docker/ # RUN echo -n 'envsubst < /usr/share/nginx/html/env.template.js > /usr/share/nginx/html/env.js\nrm /usr/share/nginx/html/env.template.js' > /docker-entrypoint.d/100-set-env.sh && chmod +x /docker-entrypoint.d/100-set-env.sh COPY --from=builder /app-builder/build /usr/share/nginx/html