Skip to content

Commit e613535

Browse files
author
Andreas Mautz
committed
[INFRA] add bookworm as stable release
1 parent 29e1661 commit e613535

16 files changed

+902
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
version: [ 'buster', 'bullseye' ]
13+
version: [ 'buster', 'bullseye', 'bookworm' ]
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v2

.github/workflows/schedule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
version: [ 'buster', 'bullseye' ]
13+
version: [ 'buster', 'bullseye', 'bookworm' ]
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v2

src/bookworm/src/Dockerfile

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
FROM openmage/debian:bookworm-latest
2+
3+
COPY root /
4+
5+
## configure default environment stuff and file permissions
6+
RUN set -xe; \
7+
chmod 755 /usr/local/bin/{docker-php-source-prepare,docker-entrypoint,docker-fpm-healthcheck,docker-php-ext-configure,docker-php-ext-enable,docker-php-ext-disable,docker-php-ext-disable,docker-php-ext-install,docker-php-pecl-install,docker-php-source,phpgosu}; \
8+
mkdir /home/www-data; \
9+
chmod 711 /home/www-data; \
10+
chown www-data:www-data /home/www-data; \
11+
usermod -d /home/www-data www-data; \
12+
\
13+
## block packages from being installed
14+
{ \
15+
echo 'Package: libjpeg*'; \
16+
echo 'Pin: release *'; \
17+
echo 'Pin-Priority: -1'; \
18+
} > /etc/apt/preferences.d/no-libjpeg; \
19+
{ \
20+
echo 'Package: libtiff*'; \
21+
echo 'Pin: release *'; \
22+
echo 'Pin-Priority: -1'; \
23+
} > /etc/apt/preferences.d/no-libtiff; \
24+
{ \
25+
echo 'Package: libwebp*'; \
26+
echo 'Pin: release *'; \
27+
echo 'Pin-Priority: -1'; \
28+
} > /etc/apt/preferences.d/no-libwebp;
29+
30+
ARG IMAGICK_RUNTIME_REQUIREMENTS="libpng16-16 liblcms2-2 libgomp1 libltdl7 bzip2 gosu brotli"
31+
ARG IMAGICK_RUNTIME_REQUIREMENTS_EXTRA=""
32+
ARG IMAGICK_BUILD_REQUIREMENTS="curl cmake gcc libtool libedit-dev liblcms2-dev build-essential autoconf automake pkg-config libpng-dev libltdl-dev nasm"
33+
ARG IMAGICK_BUILD_REQUIREMENTS_EXTRA=""
34+
ARG IMAGICK_EXTRA_CONFIGURE_ARGS=""
35+
36+
ARG MOZJPEG_EXTRA_CONFIGURE_ARGS=""
37+
ARG MOZJPEG_VERSION="4.1.1"
38+
39+
ARG TIFF_VERSION="4.5.0"
40+
ARG TIFF_EXTRA_CONFIGURE_ARGS=""
41+
42+
ARG WEBP_VERSION="1.3.0"
43+
ARG WEBP_EXTRA_CONFIGURE_ARGS=""
44+
45+
ARG IMAGICK_VERSION="7.1.1-11"
46+
ARG IMAGICK_EXTRA_CONFIGURE_ARGS=""
47+
48+
ARG OPENJPEG_VERSION="2.5.0"
49+
50+
## configure imagick and the dependencies
51+
RUN set -xe; \
52+
\
53+
/usr/local/bin/docker-install-requirements imagick; \
54+
################################################
55+
## install mozjpeg
56+
################################################
57+
mkdir -p /tmp/mozjpeg; \
58+
cd /tmp/mozjpeg; \
59+
docker-package-download -o mozjpeg.tar.gz -s https://codeload.github.com/mozilla/mozjpeg/tar.gz/v${MOZJPEG_VERSION}; \
60+
tar --strip 1 -xzf mozjpeg.tar.gz; \
61+
cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib -DWITH_JPEG8=true; \
62+
make install prefix=/usr libdir=/usr/lib64 ; \
63+
################################################
64+
## install tiff
65+
################################################
66+
mkdir -p /tmp/tiff; \
67+
cd /tmp/tiff; \
68+
docker-package-download -o tiff.tar.gz -s http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz; \
69+
tar --strip 1 -xzf tiff.tar.gz; \
70+
./configure \
71+
--prefix=/usr \
72+
${TIFF_EXTRA_CONFIGURE_ARGS:-} \
73+
; \
74+
make -j$(nproc); \
75+
make install; \
76+
################################################
77+
## install webp
78+
################################################
79+
mkdir -p /tmp/libwebp; \
80+
cd /tmp/libwebp; \
81+
docker-package-download -o libwebp.tar.gz -s https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz; \
82+
tar --strip 1 -xzf libwebp.tar.gz; \
83+
./configure \
84+
--prefix=/usr \
85+
${WEBP_EXTRA_CONFIGURE_ARGS:-} \
86+
; \
87+
make -j$(nproc); \
88+
make install; \
89+
################################################
90+
## install openjpeg
91+
################################################
92+
mkdir -p /tmp/openjpeg; \
93+
cd /tmp/openjpeg; \
94+
docker-package-download -o openjpeg.tar.gz -s https://codeload.github.com/uclouvain/openjpeg/tar.gz/v${OPENJPEG_VERSION}; \
95+
tar --strip 1 -xzf openjpeg.tar.gz; \
96+
mkdir build; \
97+
cd build; \
98+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr; \
99+
make -j$(nproc); \
100+
make install; \
101+
################################################
102+
## install imagick
103+
################################################
104+
mkdir -p /tmp/imagemagick; \
105+
cd /tmp/imagemagick; \
106+
docker-package-download -o imagemagick.tar.gz -s https://codeload.github.com/ImageMagick/ImageMagick/tar.gz/${IMAGICK_VERSION}; \
107+
tar --strip 1 -xzf imagemagick.tar.gz; \
108+
./configure \
109+
--prefix=/usr \
110+
--with-webp \
111+
--without-perl \
112+
--without-x \
113+
--without-xml \
114+
--without-pango \
115+
--without-jbig \
116+
--without-wmf \
117+
--with-perl=no \
118+
--with-modules \
119+
${IMAGICK_EXTRA_CONFIGURE_ARGS:-} \
120+
; \
121+
make -j$(nproc); \
122+
make install; \
123+
/usr/local/bin/docker-layer-clean
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Package: cmake*
2+
Pin: release o=Debian,n=stretch,c=main
3+
Pin-Priority: 600

src/bookworm/src/root/etc/php-src

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PHP_URL="changeme"
2+
PHP_SHA256="changeme"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
[ "${DEBUG}" = "true" ] && set -x
3+
4+
if [ -z "${KUBERNETES_SERVICE_HOST}" ]; then
5+
HOST_DOMAIN="host.docker.internal"
6+
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
7+
if [ $? -ne 0 ]; then
8+
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
9+
echo -e "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
10+
fi
11+
fi
12+
13+
set -e
14+
15+
if [ -n "${PHP_EXT_ENABLE}" ]; then
16+
docker-php-ext-enable ${PHP_EXT_ENABLE}
17+
fi
18+
19+
DOCKER_UID=$(stat -c "%u" "${DOCUMENT_ROOT}")
20+
DOCKER_GID=$(stat -c "%g" "${DOCUMENT_ROOT}")
21+
22+
if [[ "${DOCKER_UID}" -ne "33" || "${DOCKER_GID}" -ne "33" ]] && [[ ! -f /root/.uid-gid-fixed && "${FIX_UID_GID}" = "true" ]]; then
23+
CONFLICT_USER=$(getent passwd "${DOCKER_UID}" | cut -d: -f1)
24+
CONFLICT_GROUP=$(getent group "${DOCKER_GID}" | cut -d: -f1)
25+
echo "Docker: uid = ${DOCKER_UID}, gid = ${DOCKER_GID}"
26+
echo "Conflict: user = ${CONFLICT_USER}, group = ${CONFLICT_GROUP}"
27+
# Once we've established the ids and incumbent ids then we need to free them
28+
# up (if necessary) and then make the change to www-data.
29+
CONFLICT_OFFSET=$(( $RANDOM % 10000 + 1))
30+
[ ! -z "${CONFLICT_USER}" ] && usermod -u $(expr 50000 - "${CONFLICT_OFFSET}" - "${DOCKER_UID}") "${CONFLICT_USER}"
31+
usermod -u "${DOCKER_UID}" www-data
32+
[ ! -z "${CONFLICT_GROUP}" ] && groupmod -g $(expr 50000 - "${CONFLICT_OFFSET}" - "${DOCKER_GID}") "${CONFLICT_GROUP}"
33+
groupmod -g "${DOCKER_GID}" www-data
34+
touch /root/.uid-gid-fixed
35+
fi
36+
37+
if test -f "/usr/local/bin/docker-entrypoint-custom"; then
38+
source "/usr/local/bin/docker-entrypoint-custom"
39+
fi
40+
41+
if [ "$1" = "/usr/local/bin/php" ] || [ "$1" = "php" ]; then
42+
exec gosu "${DOCKER_UID}":"${DOCKER_GID}" "$@"
43+
elif [ "$1" = "console" ]; then
44+
set -- "${@:2}"
45+
exec gosu "${DOCKER_UID}":"${DOCKER_GID}" "/bin/bash" "${@}"
46+
elif [ "$1" = "/usr/local/bin/composer" ] || [ "$1" = "composer" ]; then
47+
exec gosu "${DOCKER_UID}":"${DOCKER_GID}" "$@"
48+
elif [ "$1" = "/usr/local/bin/magerun" ] || [ "$1" = "magerun" ]; then
49+
exec gosu "${DOCKER_UID}":"${DOCKER_GID}" "$@"
50+
elif [ "$1" = "/usr/local/bin/magerun2" ] || [ "$1" = "magerun2" ]; then
51+
exec gosu "${DOCKER_UID}":"${DOCKER_GID}" "$@"
52+
elif [ "$1" = "/usr/local/sbin/php-fpm" ] || [ "$1" = "php-fpm" ]; then
53+
exec "$@"
54+
elif [ "$1" = "/usr/sbin/cron" ] || [ "$1" = "cron" ]; then
55+
if test -f "${CRONTAB_CONFIG}"; then
56+
echo "Adding crontab in ${CRONTAB_CONFIG}"
57+
/usr/bin/crontab -u www-data "${CRONTAB_CONFIG}"
58+
fi
59+
fi
60+
exec "$@"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env bash
2+
# vim: set filetype=sh :
3+
4+
# Author: <Renato Mefi [email protected]> https://github.com/renatomefi
5+
# The original code lives in https://github.com/renatomefi/php-fpm-healthcheck
6+
#
7+
# A POSIX compliant shell script to healthcheck PHP fpm status, can be used only for pinging the status page
8+
# or check for specific metrics
9+
#
10+
# i.e.: ./php-fpm-healthcheck --verbose --active-processes=6
11+
# The script will fail in case the 'active processes' is bigger than 6.
12+
#
13+
# You can combine multiple options as well, the first one to fail will fail the healthcheck
14+
# i.e.: ./php-fpm-healthcheck --listen-queue-len=10 --active-processes=6
15+
#
16+
# Ping mode (exit 0 if php-fpm returned data): ./php-fpm-healthcheck
17+
#
18+
# Ping mode with data (outputs php-fpm status text): ./php-fpm-healthcheck -v
19+
#
20+
# Exit status codes:
21+
# 2,9,111 - Couldn't connect to PHP fpm, is it running?
22+
# 8 - Couldn't reach PHP fpm status page, have you configured it with `pm.status_path = /status`?
23+
# 1 - A healthcheck condition has failed
24+
# 3 - Invalid option given
25+
# 4 - One or more required softwares are missing
26+
#
27+
# Available options:
28+
# -v|--verbose
29+
#
30+
# Metric options, fails in case the CURRENT VALUE is bigger than the GIVEN VALUE
31+
# --accepted-conn=n
32+
# --listen-queue=n
33+
# --max-listen-queue=n
34+
# --idle-processes=n
35+
# --active-processes=n
36+
# --total-processes=n
37+
# --max-active-processes=n
38+
# --max-children-reached=n
39+
# --slow-requests=n
40+
#
41+
42+
set -eu
43+
44+
OPTIND=1 # Reset getopt in case it has been used previously in the shell
45+
46+
# FastCGI variables
47+
export REQUEST_METHOD="GET"
48+
export SCRIPT_NAME="/status"
49+
export SCRIPT_FILENAME="/status"
50+
FCGI_CONNECT_DEFAULT="localhost:9000"
51+
52+
# Required software
53+
FCGI_CMD_PATH=$(command -v cgi-fcgi) || { >&2 echo "Make sure fcgi is installed (i.e. apk add --no-cache fcgi). Aborting."; exit 4; }
54+
command -v sed 1> /dev/null || { >&2 echo "Make sure sed is installed (i.e. apk add --no-cache busybox). Aborting."; exit 4; }
55+
command -v tail 1> /dev/null || { >&2 echo "Make sure tail is installed (i.e. apk add --no-cache busybox). Aborting."; exit 4; }
56+
command -v grep 1> /dev/null || { >&2 echo "Make sure grep is installed (i.e. apk add --no-cache grep). Aborting."; exit 4; }
57+
58+
# Get status from fastcgi connection
59+
# $1 - cgi-fcgi connect argument
60+
get_fpm_status() {
61+
if test "$VERBOSE" = 1; then printf "Trying to connect to php-fpm via: %s\\n" "$1"; fi;
62+
63+
# Since I cannot use pipefail I'll just split these in two commands
64+
FPM_STATUS=$(env -i REQUEST_METHOD="$REQUEST_METHOD" SCRIPT_NAME="$SCRIPT_NAME" SCRIPT_FILENAME="$SCRIPT_FILENAME" "$FCGI_CMD_PATH" -bind -connect "$1" 2> /dev/null)
65+
FPM_STATUS=$(echo "$FPM_STATUS" | tail +5)
66+
67+
if test "$VERBOSE" = 1; then printf "php-fpm status output:\\n%s\\n" "$FPM_STATUS"; fi;
68+
69+
if test "$FPM_STATUS" = "File not found."; then
70+
>&2 printf "php-fpm status page non reachable\\n";
71+
exit 8;
72+
fi;
73+
}
74+
75+
# $1 - fpm option
76+
# $2 - expected value threshold
77+
check_fpm_health_by() {
78+
OPTION=$(echo "$1" | sed 's/--//g; s/-/ /g;')
79+
VALUE_EXPECTED="$2";
80+
VALUE_ACTUAL=$(echo "$FPM_STATUS" | grep "^$OPTION" | cut -d: -f2 | sed 's/ //g')
81+
82+
if test "$VERBOSE" = 1; then printf "'%s' value '%s' and expected is less than '%s'\\n" "$OPTION" "$VALUE_ACTUAL" "$VALUE_EXPECTED"; fi;
83+
84+
if test "$VALUE_ACTUAL" -gt "$VALUE_EXPECTED"; then
85+
>&2 printf "'%s' value '%s' is greater than expected '%s'\\n" "$OPTION" "$VALUE_ACTUAL" "$VALUE_EXPECTED";
86+
exit 1;
87+
fi;
88+
}
89+
90+
PARAM_AMOUNT=0
91+
92+
# $1 - fpm option
93+
# $2 - expected value threshold
94+
check_later() {
95+
# The POSIX sh way to check if it's an integer, also the output is supressed since it's polution
96+
if ! test "$2" -eq "$2" 2> /dev/null; then
97+
>&2 printf "'%s' option value must be an integer, '%s' given\\n" "$1" "$2"; exit 3;
98+
fi
99+
100+
PARAM_AMOUNT=$(( PARAM_AMOUNT + 1 ))
101+
102+
eval "PARAM_TO_CHECK$PARAM_AMOUNT=$1"
103+
eval "VALUE_TO_CHECK$PARAM_AMOUNT=$2"
104+
}
105+
106+
# From the PARAM_TO_CHECK/VALUE_TO_CHECK magic variables, do all the checks
107+
check_fpm_health() {
108+
j=1
109+
while [ $j -le $PARAM_AMOUNT ]; do
110+
eval "CURRENT_PARAM=\$PARAM_TO_CHECK$j"
111+
eval "CURRENT_VALUE=\$VALUE_TO_CHECK$j"
112+
check_fpm_health_by "$CURRENT_PARAM" "$CURRENT_VALUE"
113+
j=$(( j + 1 ))
114+
done
115+
}
116+
117+
if ! GETOPT=$(getopt -o v --long verbose,accepted-conn:,listen-queue:,max-listen-queue:,listen-queue-len:,idle-processes:,active-processes:,total-processes:,max-active-processes:,max-children-reached:,slow-requests: -n 'php-fpm-healthcheck' -- "$@"); then
118+
>&2 echo "Invalid options, terminating." ; exit 3
119+
fi;
120+
121+
eval set -- "$GETOPT"
122+
123+
FCGI_CONNECT="${FCGI_CONNECT:-$FCGI_CONNECT_DEFAULT}"
124+
125+
VERBOSE=0
126+
127+
while test "$1"; do
128+
case "$1" in
129+
-v|--verbose ) VERBOSE=1; shift ;;
130+
--) shift ; break ;;
131+
* ) check_later "$1" "$2"; shift 2 ;;
132+
esac
133+
done
134+
135+
FPM_STATUS=false
136+
137+
get_fpm_status "$FCGI_CONNECT"
138+
check_fpm_health

0 commit comments

Comments
 (0)