2020-01-28 18:07:50 +00:00
|
|
|
### STAGE 1: Build ###
|
2021-01-11 23:29:31 +00:00
|
|
|
FROM node AS builder
|
|
|
|
RUN mkdir /app
|
|
|
|
WORKDIR /app
|
|
|
|
ADD package.json /app/
|
|
|
|
ADD package-lock.json /app/
|
2020-06-16 15:09:17 +00:00
|
|
|
COPY . /app/
|
2021-01-11 23:58:18 +00:00
|
|
|
ARG build_config=prod
|
|
|
|
RUN npm install && \
|
|
|
|
npm run build:$build_config
|
|
|
|
|
2020-02-01 15:40:34 +00:00
|
|
|
|
|
|
|
### STAGE 2: Run ###
|
2020-05-26 12:28:42 +00:00
|
|
|
FROM nginx:alpine
|
2020-05-20 18:19:33 +00:00
|
|
|
RUN set -x && apk add --update --no-cache bash libintl gettext curl
|
|
|
|
|
2020-06-16 15:09:17 +00:00
|
|
|
COPY --from=builder /app/dist/* /etc/nginx/html/
|
|
|
|
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
|
2020-05-17 02:18:16 +00:00
|
|
|
|
|
|
|
# Script for substituting environment variables
|
2020-04-15 00:20:08 +00:00
|
|
|
COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
|
2020-04-14 20:22:34 +00:00
|
|
|
RUN chmod +x ./entrypoint.sh
|
2020-05-17 02:18:16 +00:00
|
|
|
|
2020-05-26 18:48:31 +00:00
|
|
|
# Fix for Angular routing
|
|
|
|
RUN echo "pushstate: enabled" > /etc/nginx/html/Staticfile
|
|
|
|
|
2020-05-26 12:28:42 +00:00
|
|
|
# The entrypoint.sh script will run after the container finishes starting.
|
|
|
|
# Substitutes environment variables in nginx configuration and index.html,
|
2020-05-26 13:02:37 +00:00
|
|
|
# then starts/reloads nginx.
|
2020-05-26 05:51:21 +00:00
|
|
|
ENTRYPOINT ["./entrypoint.sh", \
|
2020-05-26 01:14:47 +00:00
|
|
|
"/etc/nginx/html/index.html,/etc/nginx/conf.d/default.conf", \
|
2020-06-12 20:34:21 +00:00
|
|
|
"PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,DEPLOY_URL,PORT0,GOOGLE_ANALYTICS_KEY,SENTRY_KEY,TITLE", \
|
2020-05-26 12:28:42 +00:00
|
|
|
"/etc/nginx/html", \
|
|
|
|
"true"]
|