Dockerfile 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. FROM nginx:1.19.7-alpine
  2. # Add bash for boot cmd
  3. RUN apk add bash
  4. # Add nginx.conf to container
  5. COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
  6. COPY --chown=nginx:nginx start.sh /app/start.sh
  7. # set workdir
  8. WORKDIR /app
  9. # permissions and nginx user for tightened security
  10. RUN chown -R nginx:nginx /app && chmod -R 755 /app && \
  11. chown -R nginx:nginx /var/cache/nginx && \
  12. chown -R nginx:nginx /var/log/nginx && \
  13. chmod -R 755 /var/log/nginx; \
  14. chown -R nginx:nginx /etc/nginx/conf.d
  15. RUN touch /var/run/nginx.pid && chown -R nginx:nginx /var/run/nginx.pid
  16. # # Uncomment to keep the nginx logs inside the container - Leave commented for logging to stdout and stderr
  17. # RUN mkdir -p /var/log/nginx
  18. # RUN unlink /var/log/nginx/access.log \
  19. # && unlink /var/log/nginx/error.log \
  20. # && touch /var/log/nginx/access.log \
  21. # && touch /var/log/nginx/error.log \
  22. # && chown nginx /var/log/nginx/*log \
  23. # && chmod 644 /var/log/nginx/*log
  24. USER nginx
  25. CMD ["nginx", "-g", "'daemon off;'"]