summaryrefslogtreecommitdiff
path: root/frontend/Dockerfile
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-29 13:18:37 +0100
committerGitHub <noreply@github.com>2020-10-29 13:18:37 +0100
commitcb50c427098cd73b0d4de930d35c5976f2ae919f (patch)
tree7906ae4c1620670e74f89a4649c8eac215ca087f /frontend/Dockerfile
parent93fa55749c40ed1f1a7bee9157bce81708988656 (diff)
parent59bbe732cd83595b8114971d1baa802ef8cb95cc (diff)
Merge pull request #54 from atlarge-research/build/frontend
Simplify and optimize frontend build process
Diffstat (limited to 'frontend/Dockerfile')
-rw-r--r--frontend/Dockerfile14
1 files changed, 8 insertions, 6 deletions
diff --git a/frontend/Dockerfile b/frontend/Dockerfile
index 113b09c9..dc74aa15 100644
--- a/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -1,21 +1,23 @@
-FROM node:14
+FROM node:14 AS staging
MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com>
ARG OPENDC_OAUTH_CLIENT_ID
ARG OPENDC_API_BASE_URL
-# Copy OpenDC directory
-COPY ./ /opendc
+# Copy package details
+COPY ./package.json ./yarn.lock /opendc/
+RUN cd /opendc && yarn
# Build frontend
+FROM node:14 AS build
+COPY ./ /opendc
+COPY --from=staging /opendc/node_modules /opendc/node_modules
RUN cd /opendc/ \
- && rm -rf ./build \
- && yarn \
&& export REACT_APP_OAUTH_CLIENT_ID=$OPENDC_OAUTH_CLIENT_ID \
&& export REACT_APP_API_BASE_URL=$OPENDC_API_BASE_URL \
&& yarn build
# Setup nginx to serve the frontend
FROM nginx:1.19
-COPY --from=0 /opendc/build /usr/share/nginx/html
+COPY --from=build /opendc/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf