Files
nginx-fpm-8-2/Dockerfile
2022-10-04 06:04:09 +02:00

60 lines
1.5 KiB
Docker

FROM alpine:latest
LABEL Maintainer="Christian Steinle <kontakt@steinle-computer.de>"
LABEL Description="Lightweight container with Nginx 1.22 & PHP 8.1 based on Alpine Linux."
WORKDIR /var/www/html
# Set environment variable to serve not from /var/www/html but subpath, for e.g. Laravel.
ENV SERVE_PATH=
RUN apk update && \
apk upgrade && \
apk add --no-cache \
curl \
nginx \
php81 \
php81-bcmath \
php81-ctype \
php81-curl \
php81-dom \
php81-fileinfo \
php81-fpm \
php81-gd \
php81-mbstring \
php81-mysqli \
php81-openssl \
php81-pdo \
php81-pdo_mysql \
php81-pdo_pgsql \
php81-pdo_sqlite \
php81-tokenizer \
php81-xml \
php81-xsl \
php81-zip \
supervisor
# Link to php, for calling "php artisan serve".
RUN ln -s /usr/bin/php81 /usr/bin/php
# Copy configuration and entrypoint. Entrypoint is needed to change nginx's document root if environement variable is given.
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY config/fpm-pool.conf /etc/php81/php-fpm.d/www.conf
COPY config/php.ini /etc/php81/conf.d/custom.ini
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/entrypoint.sh /bin/entrypoint.sh
RUN chmod a+x /bin/entrypoint.sh
EXPOSE 8080
RUN chown -R nobody:nobody /var/www/html /run /var/lib/nginx /var/log/nginx /etc/nginx
ENTRYPOINT ["/bin/entrypoint.sh"]
# Use unpriviledged user for security.
USER nobody
# Add healthcheck to container.
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping