-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.sh
executable file
·32 lines (26 loc) · 1.24 KB
/
startup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
NGINX_CONF=/etc/nginx/conf.d/default.conf
cd clarity-seed
# when the variable is populated a search domain entry is added to resolv.conf at startup
# this is needed for the ECS service discovery given the app works by calling host names and not FQDNs
# a search domain can't be added to the container when using the awsvpc mode
# and the awsvpc mode is needed for A records (bridge only supports SRV records)
if [ $SEARCH_DOMAIN ]; then echo "search ${SEARCH_DOMAIN}" >> /etc/resolv.conf; fi
sed -i -- 's#/usr/share/nginx/html#/clarity-seed/'$UI_ENV'/dist#g' $NGINX_CONF
# this adds the reverse proxy configuration to nginx
# everything that hits /api is proxied to the app server
if ! grep -q "location /api" "$NGINX_CONF"; then
eval "cat <<EOF
location /api {
proxy_pass http://yelb-appserver:4567/api;
proxy_http_version 1.1;
}
gzip on;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gunzip on;
EOF
" > /proxycfg.txt
# echo " proxy_set_header Host $host;" >> /proxycfg.txt
sed --in-place '/server_name localhost;/ r /proxycfg.txt' $NGINX_CONF
fi
nginx -g "daemon off;"