From 6a7024f0dea1bc030bf3ccc894bff922696a5e59 Mon Sep 17 00:00:00 2001 From: Arnold Galovics Date: Wed, 24 Aug 2022 13:10:23 +0200 Subject: [PATCH] Ability to parameterize build --- Dockerfile | 18 +++++++++++++++--- docker-compose.yml | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b393dc22..3fe094188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,14 @@ ############### ### STAGE 1: Build app ############### -FROM node:16-alpine as builder +ARG BUILDER_IMAGE=node:16-alpine +ARG NGINX_IMAGE=nginx:1.19.3 + +FROM $BUILDER_IMAGE as builder +ARG NPM_REGISTRY_URL=https://registry.npmjs.org/ +ARG BUILD_ENVIRONMENT_OPTIONS="--configuration production" +ARG PUPPETEER_DOWNLOAD_HOST_ARG=https://storage.googleapis.com +ARG PUPPETEER_CHROMIUM_REVISION_ARG=1011831 RUN apk add --no-cache git @@ -9,22 +16,27 @@ WORKDIR /usr/src/app ENV PATH /usr/src/app/node_modules/.bin:$PATH +# Export Puppeteer env variables for installation with non-default registry. +ENV PUPPETEER_DOWNLOAD_HOST $PUPPETEER_DOWNLOAD_HOST_ARG +ENV PUPPETEER_CHROMIUM_REVISION $PUPPETEER_CHROMIUM_REVISION_ARG + COPY ./ /usr/src/app/ RUN npm cache clear --force RUN npm config set fetch-retry-maxtimeout 120000 +RUN npm config set registry $NPM_REGISTRY_URL --location=global RUN npm install --location=global @angular/cli@12.2.17 RUN npm install -RUN ng build --configuration production --output-path=/dist +RUN ng build --output-path=/dist $BUILD_ENVIRONMENT_OPTIONS ############### ### STAGE 2: Serve app with nginx ### ############### -FROM nginx:alpine +FROM $NGINX_IMAGE COPY --from=builder /dist /usr/share/nginx/html diff --git a/docker-compose.yml b/docker-compose.yml index ccaf94cc9..e665cc031 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,13 @@ services: build: context: . dockerfile: Dockerfile + args: + - BUILD_ENVIRONMENT_OPTIONS="--configuration production" + - BUILDER_IMAGE=node:16-alpine + - NGINX_IMAGE=nginx:1.19.3 + - NPM_REGISTRY_URL=https://registry.npmjs.org/ + - PUPPETEER_DOWNLOAD_HOST_ARG=https://storage.googleapis.com + - PUPPETEER_CHROMIUM_REVISION_ARG=1011831 ports: - '4200:80' environment: