2019-07-21 14:39:32 +08:00
|
|
|
FROM alpine:3.10
|
2017-01-21 19:05:00 +08:00
|
|
|
LABEL Maintainer="Tim de Pater <code@trafex.nl>" \
|
2019-07-21 14:39:32 +08:00
|
|
|
Description="Lightweight container with Nginx 1.16 & PHP-FPM 7.3 based on Alpine Linux."
|
2016-02-16 01:20:56 +08:00
|
|
|
|
2017-08-21 16:50:35 +08:00
|
|
|
# Install packages
|
2017-03-28 19:58:02 +08:00
|
|
|
RUN apk --no-cache add php7 php7-fpm php7-mysqli php7-json php7-openssl php7-curl \
|
2019-08-03 20:39:20 +08:00
|
|
|
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \
|
2017-08-21 16:50:35 +08:00
|
|
|
php7-mbstring php7-gd nginx supervisor curl
|
2016-02-24 18:08:50 +08:00
|
|
|
|
|
|
|
# Configure nginx
|
2016-03-16 20:34:24 +08:00
|
|
|
COPY config/nginx.conf /etc/nginx/nginx.conf
|
2019-11-05 21:27:04 +08:00
|
|
|
# Remove default server definition
|
|
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
2016-02-24 18:08:50 +08:00
|
|
|
|
|
|
|
# Configure PHP-FPM
|
2019-01-26 20:54:53 +08:00
|
|
|
COPY config/fpm-pool.conf /etc/php7/php-fpm.d/www.conf
|
2019-11-06 15:48:30 +08:00
|
|
|
COPY config/php.ini /etc/php7/conf.d/custom.ini
|
2016-03-16 20:34:24 +08:00
|
|
|
|
|
|
|
# Configure supervisord
|
|
|
|
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
2016-02-24 18:08:50 +08:00
|
|
|
|
2019-01-26 20:54:53 +08:00
|
|
|
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
|
2019-01-27 15:08:54 +08:00
|
|
|
RUN chown -R nobody.nobody /run && \
|
|
|
|
chown -R nobody.nobody /var/lib/nginx && \
|
2019-01-26 20:54:53 +08:00
|
|
|
chown -R nobody.nobody /var/tmp/nginx && \
|
2019-01-27 15:08:54 +08:00
|
|
|
chown -R nobody.nobody /var/log/nginx
|
2019-01-26 20:54:53 +08:00
|
|
|
|
|
|
|
# Setup document root
|
2016-02-24 18:08:50 +08:00
|
|
|
RUN mkdir -p /var/www/html
|
2019-01-26 20:54:53 +08:00
|
|
|
|
2019-07-21 14:20:03 +08:00
|
|
|
# Make the document root a volume
|
|
|
|
VOLUME /var/www/html
|
|
|
|
|
2019-01-26 20:54:53 +08:00
|
|
|
# Switch to use a non-root user from here on
|
|
|
|
USER nobody
|
|
|
|
|
|
|
|
# Add application
|
2016-02-24 18:08:50 +08:00
|
|
|
WORKDIR /var/www/html
|
2019-01-26 20:54:53 +08:00
|
|
|
COPY --chown=nobody src/ /var/www/html/
|
|
|
|
|
|
|
|
# Expose the port nginx is reachable on
|
|
|
|
EXPOSE 8080
|
2016-02-16 17:13:29 +08:00
|
|
|
|
2019-01-26 20:54:53 +08:00
|
|
|
# Let supervisord start nginx & php-fpm
|
2016-03-16 20:34:24 +08:00
|
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
2019-01-05 16:27:58 +08:00
|
|
|
|
2019-01-26 20:54:53 +08:00
|
|
|
# Configure a healthcheck to validate that everything is up&running
|
2019-01-27 15:01:52 +08:00
|
|
|
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping
|