diff --git a/Dockerfile b/Dockerfile index 6b580612..34afefa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,10 +25,16 @@ COPY --from=builder /app/dist /usr/share/nginx/html COPY docker/nginx.conf /etc/nginx/conf.d/default.conf COPY docker/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +# Run fully as non-root (port 8080 is unprivileged). nginx needs to own: +# its runtime dirs, the config it rewrites at startup (PORT envsubst), +# and the html dir (entrypoint writes env.js there). +RUN chmod +x /entrypoint.sh \ + && touch /var/run/nginx.pid \ + && chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid \ + /etc/nginx/conf.d /usr/share/nginx/html + +USER nginx -# Drop root: nginx master runs as root for port binding, workers as nginx -# The entrypoint writes env.js before exec-ing nginx EXPOSE 8080 ENTRYPOINT ["/entrypoint.sh"]