alpine-php7-webserver/Dockerfile

105 lines
2.7 KiB
Text
Raw Permalink Normal View History

2024-12-03 15:40:44 +01:00
ARG ARCH=
FROM ${ARCH}alpine:3.13
2024-12-03 16:59:44 +01:00
LABEL Maintainer="Andreas Holzmann <support@h2-invent.com>" \
2024-12-03 15:40:44 +01:00
Description="Lightweight container with Nginx & PHP-FPM based on Alpine Linux."
# Install packages
RUN apk --no-cache add \
php7 \
php7-ctype \
php7-curl \
php7-dom \
php7-exif \
php7-fileinfo \
php7-fpm \
php7-gd \
php7-iconv \
php7-intl \
php7-json \
php7-mbstring \
php7-mysqli \
php7-opcache \
php7-openssl \
php7-pecl-apcu \
php7-pdo \
php7-pdo_mysql \
php7-pgsql \
php7-phar \
php7-session \
php7-simplexml \
php7-soap \
php7-sodium \
php7-tokenizer \
php7-xml \
php7-xmlreader \
php7-zip \
php7-zlib \
2024-12-03 15:41:51 +01:00
php7-xmlwriter \
php7-xsl \
php7-pcntl \
php7-posix \
php7-sockets \
2024-12-03 15:40:44 +01:00
nginx \
runit \
curl \
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
&& apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/ \
# Remove alpine cache
&& rm -rf /var/cache/apk/* \
# Remove default server definition
&& rm /etc/nginx/conf.d/default.conf \
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
&& chown -R nobody.nobody /run \
&& chown -R nobody.nobody /var/lib/nginx \
&& chown -R nobody.nobody /var/log/nginx
# Add configuration files
COPY --chown=nobody rootfs/ /
# Switch to use a non-root user from here on
USER nobody
# Add application
WORKDIR /var/www/html
# Expose the port nginx is reachable on
EXPOSE 8080
# Let runit start nginx & php-fpm
CMD [ "/bin/docker-entrypoint.sh" ]
# Configure a healthcheck to validate that everything is up&running
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping
ENV nginx_root_directory=/var/www/html \
client_max_body_size=2M \
clear_env=no \
allow_url_fopen=On \
allow_url_include=Off \
display_errors=Off \
file_uploads=On \
max_execution_time=0 \
max_input_time=-1 \
max_input_vars=1000 \
2024-12-03 19:22:45 +01:00
memory_limit=512M \
2024-12-03 15:40:44 +01:00
post_max_size=8M \
upload_max_filesize=2M \
zlib_output_compression=On \
2024-12-03 15:45:02 +01:00
date_timezone=UTC \
intl_default_locale=en_US