From ad319daf159aeffce5870d9d5ffb9daed95f91b3 Mon Sep 17 00:00:00 2001 From: Lukas Brabec Date: Feb 27 2020 08:56:06 +0000 Subject: dockerization --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e87d305 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +build +node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef43307 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:8 as react-build +WORKDIR /app +COPY . ./ +RUN chmod -v +x ./start.sh +RUN yarn +RUN yarn build + + +FROM nginx:alpine +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=react-build /app/build /usr/share/nginx/html +COPY --from=react-build /app/start.sh /start.sh +EXPOSE 80 +CMD ["/start.sh"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..8e972e1 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + + location / { + index index.html; + try_files $uri /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/public/env.js b/public/env.js index 997a556..951327d 100644 --- a/public/env.js +++ b/public/env.js @@ -1,4 +1,4 @@ window.env = { SUBDIR: '/landing_page', - ORACULUM_API_URL_v1: "http://localhost:5000/api/v1/" + ORACULUM_API_URL_v1: 'http://localhost:5000/api/v1/' }; diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..3585431 --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +sed -i "s#SUBDIR: '.*',#SUBDIR: '$SUBDIR',#" /usr/share/nginx/html/env.js +sed -i "s#ORACULUM_API_URL_v1: '.*'#ORACULUM_API_URL_v1: '$API'#" /usr/share/nginx/html/env.js + +nginx -g "daemon off;"