From fac73440ba2d664efed11e118b04a76f600600c6 Mon Sep 17 00:00:00 2001 From: Imre Toth <imre.toth@ess.eu> Date: Tue, 20 Jul 2021 14:20:03 +0200 Subject: [PATCH] Building, and serving web UI via NGINX --- Dockerfile | 24 +++++++++++++++++++----- docker/default.conf | 8 ++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 docker/default.conf diff --git a/Dockerfile b/Dockerfile index fd7060ff..6704172d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,21 @@ -FROM node:alpine -MAINTAINER John Sparger +# build CCCE Frontend +FROM node:14.15.4 as builder +RUN mkdir /usr/src/app +WORKDIR /usr/src/app +ENV PATH /usr/src/app/node_modules/.bin:$PATH +COPY package.json /usr/src/app/ +RUN npm install +RUN npm install react-scripts@4.0.1 -g +COPY . /usr/src/app +ENV PUBLIC_URL "/" +ENV REACT_APP_LOGIN_METHOD "STD" +RUN npm run build -RUN mkdir /web -WORKDIR /web +# production environment +FROM nginx:1.19.6-alpine +RUN rm -rf /etc/nginx/conf.d +RUN mkdir /etc/nginx/conf.d +COPY docker/default.conf /etc/nginx/conf.d +COPY --from=builder /usr/src/app/build /usr/share/nginx/html/ EXPOSE 8080 -CMD PORT=8080 /usr/local/bin/npm start \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker/default.conf b/docker/default.conf new file mode 100644 index 00000000..d6a77f84 --- /dev/null +++ b/docker/default.conf @@ -0,0 +1,8 @@ +server { + listen 8080; + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file -- GitLab