diff --git a/Dockerfile b/Dockerfile index 9abb4089..c53ebafe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN apt update RUN apt install -y curl htop RUN apt install -y nginx RUN apt install -y libdbi-perl libdbd-pg-perl +RUN apt install -y gettext # move build files to container COPY service/build /opt/service diff --git a/docker/production/entrypoint.sh b/docker/production/entrypoint.sh index d0c2a639..2f3abe8a 100644 --- a/docker/production/entrypoint.sh +++ b/docker/production/entrypoint.sh @@ -9,6 +9,13 @@ nginx -v export GIN_MODE=release /opt/service/ivory & +# insert base url +envsubst '\$BASE_URL' < /etc/nginx/nginx.conf > "/etc/nginx/nginx.conf.tmp" && mv "/etc/nginx/nginx.conf.tmp" "/etc/nginx/nginx.conf" +if [ -n "${BASE_URL}" ]; then + sed -i "s/location \//location \\${BASE_URL}/g" /etc/nginx/nginx.conf + sed -i "s/api/\/api/g" /etc/nginx/nginx.conf +fi + # run nginx server /usr/sbin/nginx & diff --git a/docker/production/nginx.conf b/docker/production/nginx.conf index 98f787df..89dd1fba 100644 --- a/docker/production/nginx.conf +++ b/docker/production/nginx.conf @@ -10,12 +10,13 @@ http { listen 80; location / { - root /opt/web; + alias /opt/web/; index index.html; try_files $uri $uri/ =404; } location /api { + rewrite ${BASE_URL}(.*) $1 break; proxy_set_header Connection ''; proxy_pass http://localhost:8080; # we need this for events-stream we don't want to gzip or cache any data