rework all docker images to use debian slim
This commit is contained in:
parent
9d5a6833ae
commit
62036249fd
10 changed files with 180 additions and 103 deletions
98
Dockerfile-php
Normal file
98
Dockerfile-php
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
FROM debian:bookworm-slim
|
||||
|
||||
ARG PHP_VERSION=7.4
|
||||
ARG WKHTML=""
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
|
||||
# persistent / runtime deps
|
||||
RUN apt-get install -y --no-install-recommends ca-certificates curl apt-transport-https lsb-release
|
||||
|
||||
RUN set -eux; [ ! -d /var/www/html ]; mkdir -p /var/www/html; chown www-data:www-data /var/www/html; chmod 1777 /var/www/html
|
||||
|
||||
ENV APACHE_CONFDIR /etc/apache2
|
||||
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get install -y --no-install-recommends apache2; \
|
||||
\
|
||||
# generically convert lines like
|
||||
# export APACHE_RUN_USER=www-data
|
||||
# into
|
||||
# : ${APACHE_RUN_USER:=www-data}
|
||||
# export APACHE_RUN_USER
|
||||
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
|
||||
sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
|
||||
\
|
||||
# setup directories and permissions
|
||||
. "$APACHE_ENVVARS"; \
|
||||
for dir in \
|
||||
"$APACHE_LOCK_DIR" \
|
||||
"$APACHE_RUN_DIR" \
|
||||
"$APACHE_LOG_DIR" \
|
||||
; do \
|
||||
rm -rvf "$dir"; \
|
||||
mkdir -p "$dir"; \
|
||||
chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
||||
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
||||
chmod 1777 "$dir"; \
|
||||
done; \
|
||||
\
|
||||
# delete the "index.html" that installing Apache drops in here
|
||||
rm -rvf /var/www/html/*; \
|
||||
\
|
||||
# logs should go to stdout / stderr
|
||||
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
|
||||
ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \
|
||||
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"
|
||||
|
||||
# PHP files based on PHP_VERSION
|
||||
RUN curl -L https://packages.sury.org/php/apt.gpg -o /etc/apt/trusted.gpg.d/php.gpg
|
||||
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install readline-common git zlib1g-dev \
|
||||
php${PHP_VERSION} php${PHP_VERSION}-bcmath php${PHP_VERSION}-cli php${PHP_VERSION}-common \
|
||||
php${PHP_VERSION}-curl php${PHP_VERSION}-fpm php${PHP_VERSION}-gd php${PHP_VERSION}-gmp \
|
||||
php${PHP_VERSION}-imagick php${PHP_VERSION}-intl php${PHP_VERSION}-mbstring \
|
||||
php${PHP_VERSION}-mysql php${PHP_VERSION}-opcache php${PHP_VERSION}-readline php${PHP_VERSION}-sqlite3 \
|
||||
php${PHP_VERSION}-xml php${PHP_VERSION}-yaml php${PHP_VERSION}-zip \
|
||||
libapache2-mod-php${PHP_VERSION}
|
||||
|
||||
# specific PHP modules for some versions
|
||||
RUN if [[ "${PHP_VERSION}" == "7.4" ]] ; then apt-get -y install php${PHP_VERSION}-json; fi
|
||||
|
||||
# install wkhtml if needed
|
||||
RUN if [[ "${WKHTML}" != "" ]] ; then \
|
||||
apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev; \
|
||||
apt-get install --no-install-recommends -y fontconfig libfreetype6 libjpeg62-turbo libpng16-16 libx11-6 libxcb1 libxext6 libxrender1 xfonts-75dpi xfonts-base; \
|
||||
curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_arm64.deb -o /tmp/wkhtmltox.deb; \
|
||||
dpkg -i /tmp/wkhtmltox.deb; \
|
||||
fi
|
||||
|
||||
# symbolic link for easy use of php.ini
|
||||
RUN ln -s /etc/php/${PHP_VERSION}/apache2/conf.d /etc/php/conf.d
|
||||
|
||||
# apache site and modules
|
||||
COPY apache/site.conf /etc/apache2/sites-available/site.conf
|
||||
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
||||
RUN a2dissite 000-default
|
||||
RUN a2dismod mpm_event && a2enmod mpm_prefork # Apache + PHP requires preforking Apache for best results
|
||||
RUN a2enmod rewrite
|
||||
RUN a2enmod remoteip
|
||||
RUN a2ensite site
|
||||
|
||||
# email relay
|
||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
||||
|
||||
# clean all
|
||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
||||
|
||||
# apache init
|
||||
COPY apache/apache2-foreground /usr/local/bin/apache2-foreground
|
||||
RUN chmod +x /usr/local/bin/apache2-foreground
|
||||
WORKDIR /var/www/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue