diff --git a/.dockerignore b/.dockerignore index c55cfec1..e218479a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,6 +11,7 @@ !/src/** !package.json !package-lock.json +!nginx.conf # !.babelrc !config-overrides.js !postcss.config.js diff --git a/Dockerfile b/Dockerfile index bc4ddcb1..cce5cde3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14 +FROM node:14 as builder_base WORKDIR discovery-web-ui @@ -10,3 +10,21 @@ COPY package.json \ RUN npm ci COPY . ./ + +FROM builder_base as builder_production + +ARG DATA_HOST +ENV DATA_HOST=${DATA_HOST} + +RUN sed -e s@DATA_HOST@$DATA_HOST@g /discovery-web-ui/config/config.js.template > /discovery-web-ui/src/config.js + +RUN SKIP_PREFLIGHT_CHECK=true NODE_ENV=production npm run-script build + +# production environment +FROM nginx:1.15.7-alpine as production + +COPY --from=builder_production /discovery-web-ui/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=builder_production /discovery-web-ui/build /usr/share/nginx/html + +CMD ["nginx", "-g", "daemon off;"] + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..ffa6048c --- /dev/null +++ b/nginx.conf @@ -0,0 +1,13 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file