# The server builds from the repository root; dist/ already contains engine.wasm.
# A tested base digest can be supplied with --build-arg NGINX_IMAGE=...@sha256:....
ARG NGINX_IMAGE=nginx/nginx-unprivileged:stable-alpine
FROM ${NGINX_IMAGE}

USER root
RUN rm -rf /usr/share/nginx/html/*
COPY --chown=101:101 deploy/nginx.conf /etc/nginx/nginx.conf
COPY --chown=101:101 dist/ /usr/share/nginx/html/

USER 101:101
WORKDIR /usr/share/nginx/html
EXPOSE 8080
STOPSIGNAL SIGQUIT

# Bypass base-image entrypoint scripts: the runtime filesystem is read-only.
# Kubernetes supplies a writable emptyDir at /tmp for nginx's PID/temp files.
ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]
