Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Run nginx in foreground.
# daemon off;

# This is run inside Docker.
user nginx;

# Pid storage location.
pid /run/nginx.pid;
pid /tmp/nginx.pid;

# Set number of worker processes.
worker_processes 1;
Expand Down Expand Up @@ -41,8 +38,8 @@ http {
resolver 127.0.0.11 ipv6=off;

server {
listen 80;
listen [::]:80;
listen ${NGINX_PORT};
listen [::]:${NGINX_PORT};
server_name localhost;

location / {
Expand Down Expand Up @@ -90,4 +87,4 @@ http {
proxy_set_header X-Real-IP $remote_addr;
}
}
}
}
6 changes: 3 additions & 3 deletions .docker/scripts/100-envsubst-on-app-envs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -ex
# find the file with the template envs
envs=$(ls -t /usr/share/nginx/html/assets/envs*.js | head -n1)

envsubst < "$envs" > ./envs_temp
cp ./envs_temp "$envs"
rm ./envs_temp
tmpfile=$(mktemp)
envsubst < "$envs" > "$tmpfile"
mv "$tmpfile" "$envs"
9 changes: 9 additions & 0 deletions .docker/scripts/90-envsubst-on-nginx-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

set -ex

config_file="/etc/nginx/nginx.conf"

tmpfile=$(mktemp)
envsubst '${NGINX_PORT}' < "$config_file" > "$tmpfile"
mv "$tmpfile" "$config_file"
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM nginx:alpine-slim AS prod
FROM nginxinc/nginx-unprivileged:alpine-slim AS prod

EXPOSE 80

COPY .docker/scripts/ /docker-entrypoint.d/
COPY .docker/nginx.conf /etc/nginx/
ENV NGINX_PORT=80

RUN chmod +x /docker-entrypoint.d/100-envsubst-on-app-envs.sh
EXPOSE 80

COPY dist/ /usr/share/nginx/html/
COPY --chmod=755 .docker/scripts/ /docker-entrypoint.d/
COPY --chown=nginx:root .docker/nginx.conf /etc/nginx/
COPY --chown=nginx:root dist/ /usr/share/nginx/html/