2020-11-17 02:22:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# https://www.freecodecamp.org/news/how-to-implement-runtime-environment-variables-with-create-react-app-docker-and-nginx-7f9d42a91d70/
|
|
|
|
#
|
|
|
|
|
2020-11-20 00:03:44 +00:00
|
|
|
# Recreate js config file on start
|
2020-11-17 02:22:28 +00:00
|
|
|
rm -rf ${PUBLIC_DIR}/env-config.js
|
|
|
|
touch ${PUBLIC_DIR}/env-config.js
|
|
|
|
|
2020-11-20 00:03:44 +00:00
|
|
|
# Add runtime base url assignment
|
|
|
|
echo "window._env_ = {PROD_URL: \"https://${API_HOST}\"}" >> ${PUBLIC_DIR}/env-config.js
|
|
|
|
|
|
|
|
nginx_config="$(cat << EOF
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
charset utf-8;
|
|
|
|
|
|
|
|
location / {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
try_files \$uri \$uri/ /index.html;
|
|
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
|
|
|
add_header Pragma "no-cache";
|
|
|
|
}
|
|
|
|
|
|
|
|
error_log /var/log/nginx/app-error.log;
|
|
|
|
access_log /var/log/nginx/app-access.log;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
|
|
|
|
echo "${nginx_config}" > /etc/nginx/conf.d/default.conf
|