| 1 | FROM docker.io/nginxinc/nginx-unprivileged:1.27-alpine3.20 |
| 2 | |
| 3 | # Temporarily switch to root to install packages and create symlink in restricted location |
| 4 | USER root |
| 5 | RUN apk update && apk add --no-cache jq curl |
| 6 | |
| 7 | COPY dist/app /usr/share/nginx/html |
| 8 | COPY docker/default.conf.template etc/nginx/templates/default.conf.template |
| 9 | # Before starting nginx, apply ENV vars to create app-config.json from AUTHORITY_PORTAL_FRONTEND_* ENV Vars |
| 10 | # Use an entrypoint drop-in instead of modifying the default entrypoint or command, |
| 11 | # so that the automatic envsubst templating is not disabled. |
| 12 | COPY docker/99-generate-app-config.sh /docker-entrypoint.d/99-generate-app-config.sh |
| 13 | |
| 14 | RUN ln -sf /tmp/app-config.json /usr/share/nginx/html/assets/config/app-configuration.json \ |
| 15 | # Nginx is configured to reject symlinks that point to a file owned by a different user, for security reasons |
| 16 | && chown --no-dereference nginx:root /usr/share/nginx/html/assets/config/app-configuration.json |
| 17 | |
| 18 | # Switch back to unprivileged user for runtime |
| 19 | USER nginx:nginx |
| 20 | |
| 21 | ENV NGINX_BIND="0.0.0.0" |
| 22 | ENV NGINX_PORT=8080 |
| 23 | |
| 24 | HEALTHCHECK --interval=2s --timeout=5s --retries=10 \ |
| 25 | CMD curl -f http://${NGINX_BIND:"localhost"}:$NGINX_PORT/ || exit 1 |