2021-01-19 00:23:07 +08:00
|
|
|
FROM alpine:3.13
|
2017-01-21 19:05:00 +08:00
|
|
|
LABEL Maintainer="Tim de Pater <code@trafex.nl>" \
|
2021-04-14 04:43:03 +08:00
|
|
|
Description="Lightweight container with Nginx 1.18 & PHP 8.0 based on Alpine Linux."
|
2016-02-16 01:20:56 +08:00
|
|
|
|
2020-06-11 09:24:55 +08:00
|
|
|
# Install packages and remove default server definition
|
2021-04-14 04:43:03 +08:00
|
|
|
RUN apk --no-cache add php8 php8-fpm php8-opcache php8-mysqli php8-json php8-openssl php8-curl \
|
|
|
|
php8-zlib php8-xml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype php8-session \
|
|
|
|
php8-mbstring php8-gd nginx supervisor curl && \
|
2020-06-11 09:24:55 +08:00
|
|
|
rm /etc/nginx/conf.d/default.conf
|
2016-02-24 18:08:50 +08:00
|
|
|
|
2021-05-17 19:03:59 +08:00
|
|
|
# Create symlink so programs depending on `php` still function
|
|
|
|
RUN ln -s /usr/bin/php8 /usr/bin/php
|
|
|
|
|
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
|
2016-02-24 18:08:50 +08:00
|
|
|
|
|
|
|
# Configure PHP-FPM
|
2021-04-14 04:43:03 +08:00
|
|
|
COPY config/fpm-pool.conf /etc/php8/php-fpm.d/www.conf
|
|
|
|
COPY config/php.ini /etc/php8/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
|
|
|
|
2020-02-03 03:36:51 +08:00
|
|
|
# Setup document root
|
|
|
|
RUN mkdir -p /var/www/html
|
|
|
|
|
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
|
2020-02-03 03:36:51 +08:00
|
|
|
RUN chown -R nobody.nobody /var/www/html && \
|
|
|
|
chown -R nobody.nobody /run && \
|
2019-01-27 15:08:54 +08:00
|
|
|
chown -R nobody.nobody /var/lib/nginx && \
|
|
|
|
chown -R nobody.nobody /var/log/nginx
|
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
|