Dockerfile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. FROM nginx:alpine
  2. LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
  3. COPY nginx.conf /etc/nginx/
  4. # If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
  5. ARG CHANGE_SOURCE=false
  6. RUN if [ ${CHANGE_SOURCE} = true ]; then \
  7. # Change application source from dl-cdn.alpinelinux.org to aliyun source
  8. sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
  9. ;fi
  10. RUN apk update \
  11. && apk upgrade \
  12. && apk --update add logrotate \
  13. && apk add --no-cache openssl \
  14. && apk add --no-cache bash
  15. RUN apk add --no-cache curl
  16. RUN set -x ; \
  17. addgroup -g 82 -S www-data ; \
  18. adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
  19. ARG PHP_UPSTREAM_CONTAINER=php-fpm
  20. ARG PHP_UPSTREAM_PORT=9000
  21. # Create 'messages' file used from 'logrotate'
  22. RUN touch /var/log/messages
  23. # Copy 'logrotate' config file
  24. COPY logrotate/nginx /etc/logrotate.d/
  25. # Set upstream conf and remove the default conf
  26. RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
  27. && rm /etc/nginx/conf.d/default.conf
  28. ADD ./startup.sh /opt/startup.sh
  29. RUN sed -i 's/\r//g' /opt/startup.sh
  30. CMD ["/bin/bash", "/opt/startup.sh"]
  31. EXPOSE 80 81 443