Skip to content

Commit 8a8c667

Browse files
committed
Add debian12 image
1 parent 65936f7 commit 8a8c667

24 files changed

Lines changed: 665 additions & 3 deletions

File tree

.github/workflows/multi-build-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
build_and_push:
1818
strategy:
1919
matrix:
20-
version: ["debian11"]
20+
version: ["debian12", "debian11"]
2121

2222
runs-on: ubuntu-latest
2323
steps:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SUBDIRS := centos7 centos7-develop debian9 debian10 debian11 sid
1+
SUBDIRS := centos7 centos7-develop debian9 debian10 debian11 debian12 sid
22

33
.PHONY: build push clean
44

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ These images are available from the [Docker Hub](https://hub.docker.com/r/panubo
88

99
## Production Images
1010

11-
- [Debian 10 (Buster) Base](/debian10) - Recommended for PHP applications that support PHP 7.3
1211
- [Debian 11 (Bullseye) Base](/debian11) - Recommended for PHP applications that support PHP 7.4
12+
- [Debian 12 (Bookworm) Base](/debian12) - Recommended for PHP applications that support PHP 8.2
1313

1414
## Development Images
1515

@@ -18,6 +18,7 @@ These images are available from the [Docker Hub](https://hub.docker.com/r/panubo
1818

1919
## Legacy
2020

21+
- [Debian 10 (Buster) Base](/debian10) - For legacy PHP applications that support PHP 7.3
2122
- [Debian 9 (Stretch) Base](/debian9) - For legacy PHP applications that support PHP 7.0
2223
- [CentOS 7 Base](/centos7) - For legacy PHP applications that require PHP 5.4
2324

debian12/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.md
2+
test

debian12/Dockerfile

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Panubo PHP-Apache
2+
#
3+
# Debian bookworm
4+
# PHP 8.2
5+
# Apache 2.4
6+
# Mongo support
7+
#
8+
9+
FROM debian:bookworm
10+
11+
# Component Versions
12+
ENV \
13+
BASHCONTAINER_VERSION=0.7.2 BASHCONTAINER_SHA256=87c4b804f0323d8f0856cb4fbf2f7859174765eccc8b0ac2d99b767cecdcf5c6 \
14+
PHPEXTRAS_VERSION=0.1.0 PHPEXTRAS_SHA256=515af5789d5180123acfac9b1090f46e07f355c8df51a34e27ada5f7da0495cc
15+
16+
# Change the www-data use to uid and gid 48 to match other containers
17+
RUN \
18+
usermod -u 48 www-data && \
19+
groupmod -g 48 www-data
20+
21+
# Install bash-container functions
22+
RUN set -x \
23+
&& if ! command -v wget > /dev/null; then \
24+
fetchDeps="${fetchDeps} wget"; \
25+
fi \
26+
&& apt-get update \
27+
&& apt-get install -y --no-install-recommends ca-certificates curl ${fetchDeps} \
28+
&& cd /tmp \
29+
&& wget -nv https://github.com/panubo/bash-container/releases/download/v${BASHCONTAINER_VERSION}/panubo-functions.tar.gz \
30+
&& echo "${BASHCONTAINER_SHA256} panubo-functions.tar.gz" > /tmp/SHA256SUM \
31+
&& ( cd /tmp; sha256sum -c SHA256SUM || ( echo "Expected $(sha256sum panubo-functions.tar.gz)"; exit 1; )) \
32+
&& tar --no-same-owner -C / -zxf panubo-functions.tar.gz \
33+
&& rm -rf /tmp/* \
34+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false ${fetchDeps} \
35+
&& apt-get clean \
36+
&& rm -rf /var/lib/apt/lists/* \
37+
;
38+
39+
# Install gomplate
40+
RUN set -x \
41+
&& GOMPLATE_VERSION=v3.11.5 \
42+
&& GOMPLATE_CHECKSUM_X86_64=16f6a01a0ff22cae1302980c42ce4f98ca20f8c55443ce5a8e62e37fc23487b3 \
43+
&& GOMPLATE_CHECKSUM_AARCH64=fd980f9d233902e50f3f03f10ea65f36a2705385358a87aa18b19fb7cdf54c1d \
44+
&& if [ "$(uname -m)" = "x86_64" ] ; then \
45+
GOMPLATE_CHECKSUM="${GOMPLATE_CHECKSUM_X86_64}"; \
46+
GOMPLATE_ARCH="amd64"; \
47+
elif [ "$(uname -m)" = "aarch64" ]; then \
48+
GOMPLATE_CHECKSUM="${GOMPLATE_CHECKSUM_AARCH64}"; \
49+
GOMPLATE_ARCH="arm64"; \
50+
fi \
51+
&& curl -sSf -o /tmp/gomplate_linux-${GOMPLATE_ARCH} -L https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_linux-${GOMPLATE_ARCH} \
52+
&& echo "${GOMPLATE_CHECKSUM} gomplate_linux-${GOMPLATE_ARCH}" > /tmp/SHA256SUM \
53+
&& ( cd /tmp; sha256sum -c SHA256SUM || ( echo "Expected $(sha256sum gomplate_linux-${GOMPLATE_ARCH})"; exit 1; )) \
54+
&& install -m 0755 /tmp/gomplate_linux-${GOMPLATE_ARCH} /usr/local/bin/gomplate \
55+
&& rm -f /tmp/* \
56+
;
57+
58+
# Install s6
59+
RUN set -x \
60+
&& S6_VERSION=2.11.0.0 \
61+
&& EXECLINE_VERSION=2.8.1.0 \
62+
&& SKAWARE_RELEASE=2.0.7 \
63+
&& S6_CHECKSUM_X86_64=fcf79204c1957016fc88b0ad7d98f150071483583552103d5822cbf56824cc87 \
64+
&& S6_CHECKSUM_AARCH64=64151e136f887c6c2c7df69e3100573c318ec7400296680cc698bc7b0ca36943 \
65+
&& EXECLINE_CHECKSUM_X86_64=b216cfc4db928729d950df5a354aa34bc529e8250b55ab0de700193693dea682 \
66+
&& EXECLINE_CHECKSUM_AARCH64=8cb1d5c2d44cb94990d63023db48f7d3cd71ead10cbb19c05b99dbd528af5748 \
67+
&& if [ "$(uname -m)" = "x86_64" ] ; then \
68+
S6_CHECKSUM="${S6_CHECKSUM_X86_64}"; \
69+
EXECLINE_CHECKSUM="${EXECLINE_CHECKSUM_X86_64}"; \
70+
SKAWARE_ARCH="amd64"; \
71+
elif [ "$(uname -m)" = "aarch64" ]; then \
72+
S6_CHECKSUM="${S6_CHECKSUM_AARCH64}"; \
73+
EXECLINE_CHECKSUM="${EXECLINE_CHECKSUM_AARCH64}"; \
74+
SKAWARE_ARCH="aarch64"; \
75+
fi \
76+
&& curl -sSf -L -o /tmp/s6-${S6_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz https://github.com/just-containers/skaware/releases/download/v${SKAWARE_RELEASE}/s6-${S6_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz \
77+
&& curl -sSf -L -o /tmp/execline-${EXECLINE_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz https://github.com/just-containers/skaware/releases/download/v${SKAWARE_RELEASE}/execline-${EXECLINE_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz \
78+
&& echo "${S6_CHECKSUM} s6-${S6_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz" > /tmp/SHA256SUM \
79+
&& echo "${EXECLINE_CHECKSUM} execline-${EXECLINE_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz" >> /tmp/SHA256SUM \
80+
&& ( cd /tmp; sha256sum -c SHA256SUM || ( echo "Expected S6: $(sha256sum s6-${S6_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz) Execline: $(sha256sum execline-${EXECLINE_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz)"; exit 1; )) \
81+
&& tar -C /usr/local -zxf /tmp/s6-${S6_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz \
82+
&& tar -C /usr/local -zxf /tmp/execline-${EXECLINE_VERSION}-linux-${SKAWARE_ARCH}-bin.tar.gz \
83+
&& rm -rf /tmp/* \
84+
;
85+
86+
# Install PHP Extras
87+
RUN set -x \
88+
&& if ! command -v wget > /dev/null; then \
89+
fetchDeps="${fetchDeps} wget"; \
90+
fi \
91+
&& apt-get update \
92+
&& apt-get install -y --no-install-recommends ${fetchDeps} \
93+
&& cd /tmp \
94+
&& wget -nv https://github.com/panubo/php-extras/releases/download/v${PHPEXTRAS_VERSION}/php-extras.tar.gz \
95+
&& echo "${PHPEXTRAS_SHA256} php-extras.tar.gz" > /tmp/SHA256SUM \
96+
&& ( cd /tmp; sha256sum -c SHA256SUM || ( echo "Expected $(sha256sum php-extras.tar.gz)"; exit 1; )) \
97+
&& mkdir -p /usr/share/php/ \
98+
&& tar --no-same-owner -C /usr/share/php/ -zxf php-extras.tar.gz \
99+
&& rm -rf /tmp/* \
100+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false ${fetchDeps} \
101+
&& apt-get clean \
102+
&& rm -rf /var/lib/apt/lists/* \
103+
;
104+
105+
# Install main packages
106+
RUN \
107+
export DEBIAN_FRONTEND=noninteractive && \
108+
apt-get update && \
109+
apt-get install --no-install-recommends --no-install-suggests -y wget curl ca-certificates git gnupg openssh-client msmtp-mta apache2 libapache2-mod-xsendfile imagemagick ghostscript \
110+
php8.2-apcu \
111+
php8.2-cli \
112+
php8.2-curl \
113+
php8.2-dom \
114+
php8.2-fpm \
115+
php8.2-gd \
116+
php8.2-igbinary \
117+
php8.2-imagick \
118+
php8.2-imap \
119+
php8.2-intl \
120+
php8.2-ldap \
121+
php8.2-mbstring \
122+
php8.2-memcached \
123+
php8.2-mongodb \
124+
php8.2-mysql \
125+
php8.2-pgsql \
126+
php8.2-pspell \
127+
php8.2-redis \
128+
php8.2-sqlite \
129+
php8.2-xmlrpc \
130+
php8.2-zip && \
131+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/www/html/*
132+
133+
# Configure
134+
RUN \
135+
mkdir -p /root/.ssh && \
136+
echo "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config && \
137+
sed -i -e '/^session.save_/ s/^/;/' /etc/php/8.2/*/php.ini && \
138+
touch /etc/php/8.2/mods-available/auto.ini && \
139+
touch /var/log/msmtp.log && \
140+
chown www-data:www-data /var/log/msmtp.log && \
141+
sed -i -r 's/^Listen.*/Listen 8000/g' /etc/apache2/ports.conf && \
142+
sed -i 's/^error_log.*/error_log = \/dev\/stderr/' /etc/php/8.2/fpm/php-fpm.conf && \
143+
sed -i -E 's/^;?systemd_interval.*/systemd_interval = 0/' /etc/php/8.2/fpm/php-fpm.conf && \
144+
mv /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/www.conf_orig && \
145+
mkdir -p /var/log/php-fpm
146+
147+
# Copy configs and templates
148+
COPY etc /etc
149+
COPY root /
150+
151+
# Enable modules / configs
152+
RUN \
153+
phpenmod session mongodb && \
154+
a2dissite 000-default && \
155+
a2disconf security other-vhosts-access-log && \
156+
phpenmod auto && \
157+
a2enconf php8.2-fpm && \
158+
a2enmod proxy_fcgi remoteip rewrite headers
159+
160+
ENV TMPDIR=/var/tmp TERM=dumb
161+
EXPOSE 8000
162+
ENTRYPOINT ["/entry.sh"]
163+
CMD ["s6"]

debian12/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
NAME = php-apache
2+
TAG = $(shell basename $(shell pwd))
3+
IMAGE_NAME := panubo/$(NAME)
4+
5+
.PHONY: help build push clean bash run
6+
7+
help:
8+
@printf "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)\n"
9+
10+
build: ## Builds docker image
11+
docker build --pull -t $(IMAGE_NAME):$(TAG) .
12+
13+
push: ## Push image to registry
14+
docker tag $(IMAGE_NAME):$(TAG) docker.io/$(IMAGE_NAME):latest
15+
docker push $(IMAGE_NAME):$(TAG)
16+
docker push $(IMAGE_NAME):latest
17+
18+
clean: ## Remove built image
19+
docker rmi $(IMAGE_NAME):$(TAG)
20+
21+
bash: ## Runs bash in the container
22+
docker run --rm -it -v $(shell pwd)/test:/srv/remote $(IMAGE_NAME):$(TAG) bash
23+
24+
run: ## Runs the container with test data
25+
docker run --rm -it -p 8000:8000 -v $(shell pwd)/test:/srv/remote --name $(NAME) $(IMAGE_NAME):$(TAG)

debian12/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# PHP-Apache Debian 12 (Bookworm)
2+
3+
This is an Apache and php-fpm image:
4+
5+
- Base: Debian 12 (Bookworm)
6+
- Apache httpd: 2.4
7+
- PHP: 8.2
8+
9+
This image is designed to be quite configurable and as such is good for getting
10+
started but probably not a great base if you want a highly optimised container.
11+
This image also expects to be used behind a load balancer and as such does not
12+
listen on port 80 but instead port 8000. Also make note of how to handle SSL
13+
offloading to the load balancer and how this affects .htaccess rules.
14+
15+
## Options:
16+
17+
All options are optional.
18+
The values shown here are the defaults. The options listed here are also case sensitive.
19+
20+
### Global
21+
22+
```
23+
timeout = 30
24+
TZ = UTC
25+
```
26+
27+
### HTTPD
28+
29+
```
30+
httpd_remoteipheader = X-Forwarded-For
31+
httpd_remoteipinternalproxy = (unset)
32+
33+
# Subdirectory within the git repository that contains the site root eg 'www'
34+
httpd_root = (unset)
35+
36+
# If unset the following is used
37+
RemoteIPInternalProxy 10.0.0.0/8
38+
RemoteIPInternalProxy 172.16.0.0/12
39+
RemoteIPInternalProxy 192.168.0.0/16
40+
```
41+
42+
### PHP/PHP-FPM
43+
44+
```
45+
phpopts_ = (unset)
46+
47+
# phpopts Examples
48+
phpopts_short_open_tag = off
49+
phpopts_post_max_size = 8M
50+
phpopts_upload_max_filesize = 2M
51+
phpopts_memory_limit = 128M
52+
53+
# PHP Cache options
54+
php_cache = (opcache|none) default is opcache, none doesn't load any cache extensions.
55+
php_apc_shm_size = 64M # This is for the apcu extension
56+
php_opcache_memory_consumption = 128
57+
php_opcache_revalidate_freq = 2
58+
59+
# PHP Session options
60+
php_session_save_handler = (unset)
61+
php_session_save_path = (unset)
62+
63+
# PHP Session examples
64+
php_session_save_handler = redis
65+
php_session_save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"
66+
67+
php_session_save_handler = memcached
68+
php_session_save_path = "host:11211"
69+
70+
# PHP-FPM options
71+
phpfpm_pm_max_children = 3
72+
phpfpm_pm_max_requests = 500
73+
```
74+
75+
### Email/msmtp
76+
77+
msmtp expects a from address to be set either via environment variable (`msmtp_from`) or
78+
in the php mail() function. eg. `mail('nobody@example.com', 'the subject',
79+
'the message', null, '-fwebmaster@example.com');`
80+
81+
msmtp also need a host to send email via, it does not queue and forward mail
82+
like postfix or exim. This could be defined via a docker link `--link
83+
smtp:smtp`
84+
85+
```
86+
msmtp_host = SMTP_PORT_25_TCP_ADDR or mail
87+
msmtp_port = SMTP_PORT_25_TCP_PORT or 25
88+
msmtp_from = (unset)
89+
msmtp_user = (unset)
90+
msmtp_pass = (unset)
91+
```
92+
93+
## PHP Pre Execution
94+
95+
PHP pre-execution helpers are included in this image. See
96+
[PHP Extras](https://github.com/panubo/php-extras) for more information.
97+
98+
Set `auto_prepend_file=xxxx_prepend.php` to enable.
99+
100+
## SSL Offloading
101+
102+
This container should be used behind a load balancing reverse proxy and as such
103+
SSL should be offloaded to the load balancer. However, this can cause issues
104+
when your applications want to know if they are being served over SSL as the
105+
local webserver cannot determine this. Below are workarounds for the two most common
106+
issues.
107+
108+
If you want to redirect users from a non-ssl connection to a SSL connection with
109+
htaccess and mod_rewrite the following rules work both behind an SSL offloading
110+
load balancer and also when the local webserver is handling the SSL.
111+
112+
```
113+
<IfModule mod_rewrite.c>
114+
RewriteEngine on
115+
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
116+
RewriteCond %{HTTPS} !=on
117+
RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R=301,L]
118+
</IfModule>
119+
```
120+
121+
Some PHP application also check they are running on an SSL connection. As the
122+
local webserver doesn't set $_SERVER['HTTPS'] correctly when behind a proxy the
123+
following code can be used to fix the issue.
124+
125+
```php
126+
/* Set _SERVER['HTTPS'] correctly when behind a proxy setting HTTP_X_FORWARDED_PROTO */
127+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
128+
$_SERVER['HTTPS'] = 'on';
129+
}
130+
```
131+
132+
or set `auto_prepend_file=SSLHelper_prepend.php` to use the SSL Helper from the [PHP Extras](https://github.com/panubo/php-extras) repo.

0 commit comments

Comments
 (0)