summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/Dockerfile
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-05 14:50:38 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-05 14:50:38 +0200
commite8bb95cb35ed1b02a85cf7cbea5bfc20fe0324c2 (patch)
tree1f3992d8045437774767556bf20d053b947ed164 /opendc-web/opendc-web-ui/Dockerfile
parent3c805a50ca710e123aa18ad1bfa01ea4f1ee40d2 (diff)
build: Support runtime variables in frontend Docker image
This change adds support for dynamically specifying various variables for the frontend Docker image through environmental variables. Previously, these were embedded directly into the source code, which requires rebuilding the entire image to change these variables.
Diffstat (limited to 'opendc-web/opendc-web-ui/Dockerfile')
-rw-r--r--opendc-web/opendc-web-ui/Dockerfile17
1 files changed, 6 insertions, 11 deletions
diff --git a/opendc-web/opendc-web-ui/Dockerfile b/opendc-web/opendc-web-ui/Dockerfile
index 20e16b08..7aa3a7bf 100644
--- a/opendc-web/opendc-web-ui/Dockerfile
+++ b/opendc-web/opendc-web-ui/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:14 AS staging
+FROM node:15 AS staging
MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com>
# Copy package details
@@ -6,21 +6,16 @@ COPY ./package.json ./yarn.lock /opendc/
RUN cd /opendc && yarn
# Build frontend
-FROM node:14 AS build
-
-ARG OPENDC_OAUTH_CLIENT_ID
-ARG OPENDC_API_BASE_URL
-ARG OPENDC_FRONTEND_SENTRY_DSN
+FROM node:15 AS build
COPY ./ /opendc
COPY --from=staging /opendc/node_modules /opendc/node_modules
RUN cd /opendc/ \
- && export REACT_APP_OAUTH_CLIENT_ID=$OPENDC_OAUTH_CLIENT_ID \
- && export REACT_APP_API_BASE_URL=$OPENDC_API_BASE_URL \
- && export REACT_APP_SENTRY_DSN=$OPENDC_FRONTEND_SENTRY_DSN \
- && yarn build
+ && yarn build \
+ && mv build/index.html build/index.html.template
# Setup nginx to serve the frontend
-FROM nginx:1.19
+FROM nginx:1.20
+COPY --from=build /opendc/scripts/envsubst-html.sh /docker-entrypoint.d/00-envsubst-html.sh
COPY --from=build /opendc/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf