Dockerfile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 set -x ; \
  16. addgroup -g 82 -S www-data ; \
  17. adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
  18. ARG PHP_UPSTREAM_CONTAINER=php-fpm
  19. ARG PHP_UPSTREAM_PORT=9000
  20. # Create 'messages' file used from 'logrotate'
  21. RUN touch /var/log/messages
  22. # Copy 'logrotate' config file
  23. COPY logrotate/nginx /etc/logrotate.d/
  24. # Set upstream conf and remove the default conf
  25. RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
  26. && rm /etc/nginx/conf.d/default.conf
  27. ADD ./startup.sh /opt/startup.sh
  28. RUN sed -i 's/\r//g' /opt/startup.sh
  29. CMD ["/bin/bash", "/opt/startup.sh"]
  30. EXPOSE 80 443