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"]
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
Only build for arm right now, based on php-apache images
|
Only build for arm right now, based on debian:bookworm-slim images and some code of php:8.2-apache, version 7.4 and 8.2
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -d --name container_name \
|
docker run -d --name container_name \
|
||||||
-v ./www:/var/www/html \
|
-v ./www:/var/www/html \
|
||||||
-v ./php:/usr/local/etc/php/conf.d \
|
-v ./php:/usr/local/etc/php/conf.d \
|
||||||
-v ./msmpt.yaml:/etc/msmtprc \
|
-v ./msmpt.yaml:/etc/msmtprc \
|
||||||
git.paucapo.com/server/php:8.2-apache
|
git.paucapo.com/server/php:8.2
|
||||||
```
|
```
|
||||||
|
|
|
||||||
40
apache/apache2-foreground
Normal file
40
apache/apache2-foreground
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background.
|
||||||
|
# (also, when run as "apache2ctl <apache args>", it does not use "exec", which leaves an undesirable resident shell process)
|
||||||
|
|
||||||
|
: "${APACHE_CONFDIR:=/etc/apache2}"
|
||||||
|
: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}"
|
||||||
|
if test -f "$APACHE_ENVVARS"; then
|
||||||
|
. "$APACHE_ENVVARS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apache gets grumpy about PID files pre-existing
|
||||||
|
: "${APACHE_RUN_DIR:=/var/run/apache2}"
|
||||||
|
: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}"
|
||||||
|
rm -f "$APACHE_PID_FILE"
|
||||||
|
|
||||||
|
# create missing directories
|
||||||
|
# (especially APACHE_RUN_DIR, APACHE_LOCK_DIR, and APACHE_LOG_DIR)
|
||||||
|
for e in "${!APACHE_@}"; do
|
||||||
|
if [[ "$e" == *_DIR ]] && [[ "${!e}" == /* ]]; then
|
||||||
|
# handle "/var/lock" being a symlink to "/run/lock", but "/run/lock" not existing beforehand, so "/var/lock/something" fails to mkdir
|
||||||
|
# mkdir: cannot create directory '/var/lock': File exists
|
||||||
|
dir="${!e}"
|
||||||
|
while [ "$dir" != "$(dirname "$dir")" ]; do
|
||||||
|
dir="$(dirname "$dir")"
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
absDir="$(readlink -f "$dir" 2>/dev/null || :)"
|
||||||
|
if [ -n "$absDir" ]; then
|
||||||
|
mkdir -p "$absDir"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "${!e}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exec apache2 -DFOREGROUND "$@"
|
||||||
16
apache/site.conf
Normal file
16
apache/site.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<VirtualHost *:80>
|
||||||
|
#ServerName www.example.com
|
||||||
|
|
||||||
|
ServerAdmin contact@
|
||||||
|
DocumentRoot /var/www/html
|
||||||
|
|
||||||
|
#LogLevel info ssl:warn
|
||||||
|
|
||||||
|
RemoteIPHeader CF-Connecting-IP
|
||||||
|
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
|
||||||
|
#Include conf-available/serve-cgi-bin.conf
|
||||||
|
</VirtualHost>
|
||||||
36
build.sh
36
build.sh
|
|
@ -1,19 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
PHP_VERSIONS="7.4 8.2"
|
||||||
|
WKHTML=""
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
PACKAGE="php:$1"
|
||||||
|
PHP_VERSION="$2"
|
||||||
|
echo "Building ${PACKAGE}"
|
||||||
|
docker build \
|
||||||
|
-f "${SCRIPT_DIR}/Dockerfile-php" \
|
||||||
|
-t "git.paucapo.com/server/${PACKAGE}" \
|
||||||
|
--build-arg PHP_VERSION=${PHP_VERSION} \
|
||||||
|
$3 \
|
||||||
|
"$SCRIPT_DIR"
|
||||||
|
docker push "git.paucapo.com/server/${PACKAGE}"
|
||||||
|
}
|
||||||
|
|
||||||
docker login "http://git.paucapo.com/"
|
docker login "http://git.paucapo.com/"
|
||||||
|
|
||||||
for dockerfile in $SCRIPT_DIR/*:*; do
|
for PHP_VERSION in ${PHP_VERSIONS}; do
|
||||||
package=`basename "$dockerfile"`
|
build ${PHP_VERSION} ${PHP_VERSION}
|
||||||
if [[ "$1" == "" || "$1" == "$package" ]]; then
|
|
||||||
echo "Building $package"
|
|
||||||
docker build \
|
|
||||||
-f "$dockerfile" \
|
|
||||||
-t "git.paucapo.com/server/$package" \
|
|
||||||
"$SCRIPT_DIR"
|
|
||||||
docker push "git.paucapo.com/server/$package"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
sudo docker image prune -a --force
|
for PHP_VERSION in ${WKHTML}; do
|
||||||
|
build "${PHP_VERSION}-wkhtml" "${PHP_VERSION}" "--build-arg WKHTML=1"
|
||||||
|
done
|
||||||
|
|
||||||
|
docker image prune -a --force
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
FROM php:7.4-apache
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev
|
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
|
|
||||||
RUN docker-php-ext-enable mysqli pdo pdo_mysql gd
|
|
||||||
|
|
||||||
RUN apachectl restart
|
|
||||||
|
|
||||||
RUN [ ! -f /etc/msmtprc ] && touch /etc/msmtprc
|
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
FROM php:7.4-apache
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev
|
|
||||||
|
|
||||||
RUN apt-get install --no-install-recommends -y fontconfig libfreetype6 libjpeg62-turbo libpng16-16 libx11-6 libxcb1 libxext6 libxrender1 xfonts-75dpi xfonts-base
|
|
||||||
RUN 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
|
|
||||||
RUN dpkg -i /tmp/wkhtmltox.deb;
|
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
|
|
||||||
RUN docker-php-ext-enable mysqli pdo pdo_mysql gd
|
|
||||||
|
|
||||||
RUN apachectl restart
|
|
||||||
|
|
||||||
RUN [ ! -f /etc/msmtprc ] && touch /etc/msmtprc
|
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
FROM php:8.0-apache
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev
|
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
|
|
||||||
RUN docker-php-ext-enable mysqli pdo pdo_mysql gd
|
|
||||||
|
|
||||||
RUN apachectl restart
|
|
||||||
|
|
||||||
RUN [ ! -f /etc/msmtprc ] && touch /etc/msmtprc
|
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
FROM php:8.1-apache
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev
|
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
|
|
||||||
RUN docker-php-ext-enable mysqli pdo pdo_mysql gd
|
|
||||||
|
|
||||||
RUN apachectl restart
|
|
||||||
|
|
||||||
RUN [ ! -f /etc/msmtprc ] && touch /etc/msmtprc
|
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
FROM php:8.2-apache
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
RUN apt-get install -y --no-install-recommends msmtp msmtp-mta
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev
|
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
|
|
||||||
RUN docker-php-ext-enable mysqli pdo pdo_mysql gd
|
|
||||||
|
|
||||||
RUN apachectl restart
|
|
||||||
|
|
||||||
RUN [ ! -f /etc/msmtprc ] && touch /etc/msmtprc
|
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/*
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue