From 59bbe732cd83595b8114971d1baa802ef8cb95cc Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 29 Oct 2020 01:06:01 +0100 Subject: Add support for caching node modules during Docker builds --- frontend/.dockerignore | 1 + frontend/Dockerfile | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'frontend') 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 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 -- cgit v1.2.3