Newer
Older
ARG WS_VERSION=unknown-version
ENV WS_VERSION=${WS_VERSION}
RUN apk update && apk add --virtual build-dependencies \
git \
python2 \
g++ \
make \
&& rm -rf /var/cache/apk/*
# Create vlapipe group
# and create vlapipe in vlapipe group
RUN addgroup --gid 6000 vlapipe && \
adduser --disabled-password --gecos "" --ingroup vlapipe --uid 6000 vlapipe
FROM base as dev
# set container working directory to /code
WORKDIR /code/
# copy web app from host to container
COPY ./apps/web ./
# Disable Angular Analytics prompt
ENV NG_CLI_ANALYTICS=false
# Requires build-arg WS_VERSION
# Build arg that sets Workspaces Version; defaults if no build arg is given
ENV NG_APP_WS_VERSION=${WS_VERSION}
# install node_modules
RUN npm install
# start Angular development server
CMD [ "./node_modules/.bin/ng", "serve", "--host", "0.0.0.0" ]
FROM base as base-build

Andrew Kapuscinski
committed
# Requires build-arg $env

Nathan Hertz
committed
# Build arg that sets environment; sets to "dev" if no build arg is given
ARG DEPLOY_ENV=dev
ENV DEPLOY_ENV=${DEPLOY_ENV}

Andrew Kapuscinski
committed
# Requires build-arg WS_VERSION
# Build arg that sets Workspaces Version; defaults to "unknown-version" if no build arg is given

Andrew Kapuscinski
committed
ENV NG_APP_WS_VERSION=${WS_VERSION}

Andrew Kapuscinski
committed
# Switch to vlapipe
USER vlapipe

Andrew Kapuscinski
committed
# Create ~/app

Andrew Kapuscinski
committed
RUN mkdir -p /home/vlapipe/app

Andrew Kapuscinski
committed
# Set NPM environment variables for vlapipe

Andrew Kapuscinski
committed
ENV NPM_CONFIG_PREFIX=/home/vlapipe/.npm-global
ENV PATH=$PATH:/home/vlapipe/.npm-global/bin

Andrew Kapuscinski
committed

Andrew Kapuscinski
committed
# Change working directory to /home/vlapipe/app
WORKDIR /home/vlapipe/app

Andrew Kapuscinski
committed

Andrew Kapuscinski
committed
# Copy package.json to /home/vlapipe/app in the image

Andrew Kapuscinski
committed
# set ownership of content to vlapipe and the vlapipe group
COPY --chown=vlapipe:vlapipe /apps/web/package-lock.json .
COPY --chown=vlapipe:vlapipe /apps/web/package.json .
ENV NG_CLI_ANALYTICS=false

Andrew Kapuscinski
committed
# Install node modules
RUN npm install
# Switch to root
USER root

Andrew Kapuscinski
committed
# remove build packages
RUN apk del build-dependencies

Andrew Kapuscinski
committed
# Switch to vlapipe
USER vlapipe

Andrew Kapuscinski
committed
# Copy web directory to /home/vlapipe/app in the image

Andrew Kapuscinski
committed
# set ownership of content to vlapipe and the vlapipe group
COPY --chown=vlapipe:vlapipe ./apps/web ./
# Build the angular app
RUN ./node_modules/.bin/ng build --configuration=${DEPLOY_ENV} --output-path=dist

Andrew Kapuscinski
committed
#
## NGINX section of multi-stage image
#
# Use nginx base image
# Copy WS nginx config from base-build stage

Andrew Kapuscinski
committed
COPY --from=base-build /home/vlapipe/app/ws-nginx.conf.template /etc/nginx/templates/
# Remove default nginx config
RUN rm /etc/nginx/conf.d/default.conf
# Copy Angular build from base-build stage

Andrew Kapuscinski
committed
COPY --from=base-build /home/vlapipe/app/dist /usr/share/nginx/html