summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/.dockerignore1
-rw-r--r--frontend/Dockerfile14
2 files changed, 9 insertions, 6 deletions
diff --git a/frontend/.dockerignore b/frontend/.dockerignore
index 3c3629e6..dd87e2d7 100644
--- a/frontend/.dockerignore
+++ b/frontend/.dockerignore
@@ -1 +1,2 @@
node_modules
+build
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