Skip to content

Commit

Permalink
Add BASE_URL environment configuration
Browse files Browse the repository at this point in the history
Signed-off-by: dodo920306 <[email protected]>
  • Loading branch information
dodo920306 committed Sep 19, 2024
1 parent c2457ae commit 28b4016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docker/production/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &

Expand Down
3 changes: 2 additions & 1 deletion docker/production/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 28b4016

Please sign in to comment.