Runs nginx on port from environment variable

This commit is contained in:
Aaron Louie 2020-05-16 22:18:16 -04:00
parent d567497ef2
commit 9d28a472a5
3 changed files with 9 additions and 2 deletions

View File

@ -17,8 +17,15 @@ RUN npm install && \
FROM nginx
COPY --from=builder /crc-bpmn/dist/* /usr/share/nginx/html/
COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf
# Script for substituting environment variables
COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
# Substitute environment variables in nginx configuration
CMD ["./entrypoint.sh", "/etc/nginx/conf.d/default.conf"]
# Substitute environment variables in index.html
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html"]
### STAGE 3: Profit! ###

View File

@ -7,7 +7,7 @@ if [[ -z $1 ]]; then
fi
# Replace strings in the given file that have the format ${ENV_VAR}
envsubst '\$PRODUCTION \$API_URL \$IRB_URL' < "$1" > "$1".tmp && mv "$1".tmp "$1"
envsubst '\$PRODUCTION \$API_URL \$IRB_URL \$PORT0' < "$1" > "$1".tmp && mv "$1".tmp "$1"
# Set DEBUG=true in order to log the replaced file
if [ "$DEBUG" = true ] ; then

View File

@ -1,5 +1,5 @@
server {
listen 80;
listen $PORT0;
location / {
root /usr/share/nginx/html;