Compare commits

..

No commits in common. "d3e8812347ebf59696ca5facd6995b7d2cb8d9ff" and "18f5f948d22ca46362473cf1422dc051c312b564" have entirely different histories.

22 changed files with 268 additions and 226 deletions

View File

@ -1,3 +1,2 @@
.secrets
.act
examples

View File

@ -16,17 +16,17 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Container registry
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
@ -34,7 +34,7 @@ jobs:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v4
with:
tags: |
type=ref,event=branch

3
.gitignore vendored
View File

@ -1,4 +1 @@
pkg
.secrets
.idea
.vscode

View File

@ -1,80 +1,65 @@
# Install Caddy
FROM docker.io/caddy:builder-alpine AS caddy-builder
RUN xcaddy build
FROM alpine:3.17
LABEL maintainer="selim013@gmail.com"
# Install PHP
FROM docker.io/alpine
LABEL maintainer="vladimir@hodakov.me"
# Setup document root
WORKDIR /var/www/html
# Get caddy
COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy
# Install packages and remove default server definition
RUN apk add --no-cache curl \
imagemagick \
php84 \
php84-fpm \
php84-apache2 \
php84-ctype \
php84-curl \
php84-dom \
php84-ftp \
php84-gd \
php84-iconv \
php84-json \
php84-mbstring \
php84-mysqli \
php84-opcache \
php84-openssl \
php84-pgsql \
php84-sqlite3 \
php84-tokenizer \
php84-xml \
php84-zlib \
php84-zip \
supervisor
apache2 \
php81 \
php81-apache2 \
php81-ctype \
php81-curl \
php81-dom \
php81-ftp \
php81-gd \
php81-iconv \
php81-json \
php81-mbstring \
php81-mysqli \
php81-opcache \
php81-openssl \
php81-pgsql \
php81-sqlite3 \
php81-tokenizer \
php81-xml \
php81-zlib \
php81-zip \
su-exec
# Configure Caddy
COPY config/Caddyfile /etc/caddy/Caddyfile
# Configure PHP-FPM
COPY config/fpm-pool.conf /etc/php84/php-fpm.d/www.conf
COPY config/php.ini /etc/php84/conf.d/custom.ini
# Configure supervisord
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir /.config /phpbb
# Add tests app installation
COPY src/ /var/www/html/
# Add phpBB installation
ENV PHPBB_VERSION=3.3.14
ENV PHPBB_SHA256=68cd6cf3faefa175ea3892ba02c6b112e8967ed33703521c79820e35bd15ec9a
### phpBB
ENV PHPBB_VERSION 3.3.9
ENV PHPBB_SHA256 8eacc10caff2327d51019ed2677b55ff1afdc68a3a7aaeee9ac29747775fe04f
WORKDIR /tmp
RUN curl -SL https://download.phpbb.com/pub/release/3.3/${PHPBB_VERSION}/phpBB-${PHPBB_VERSION}.tar.bz2 -o phpbb.tar.bz2 \
&& echo "${PHPBB_SHA256} phpbb.tar.bz2" | sha256sum -c - \
&& tar -xjf phpbb.tar.bz2 \
&& mkdir /phpbb \
&& mkdir /phpbb/sqlite \
&& mv phpBB3 /phpbb/www \
&& rm -f phpbb.tar.bz2
COPY phpbb/config.php /phpbb/www
# Expose the ports Caddy is reachable on
EXPOSE 8080
EXPOSE 8181
### Server
RUN mkdir -p /run/apache2 /phpbb/opcache \
&& chown apache:apache /run/apache2 /phpbb/opcache
COPY apache2/httpd.conf /etc/apache2/
COPY apache2/conf.d/* /etc/apache2/conf.d/
COPY php/php.ini php/php-cli.ini /etc/php81/
COPY php/conf.d/* /etc/php81/conf.d
COPY start.sh /usr/local/bin/
RUN chown -R apache:apache /phpbb
WORKDIR /phpbb/www
#VOLUME /phpbb/sqlite
#VOLUME /phpbb/www/files
#VOLUME /phpbb/www/store
#VOLUME /phpbb/www/images/avatars/upload
ENV PHPBB_INSTALL= \
PHPBB_DB_DRIVER=sqlite3 \
PHPBB_DB_HOST=/phpbb/sqlite/sqlite.db \
@ -88,8 +73,5 @@ ENV PHPBB_INSTALL= \
PHPBB_DEBUG= \
PHPBB_DEBUG_CONTAINER=
COPY start.sh /usr/local/bin/
EXPOSE 80
CMD ["start.sh"]
# Configure a healthcheck to validate that everything is up and running
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping

View File

@ -1,7 +1,6 @@
MIT License
Copyright (c) 2016 Seleznyov Dmitry
Copyright (c) 2023-2025 Vladimir Hodakov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,15 +1,11 @@
# phpBB3 docker image
This is updated fork of [selim13's docker-phpbb image](https://github.com/selim13/docker-phpbb).
Now it even bundles caddy instead of apache2. Thanks
[ParaParty/docker-php-caddy](https://github.com/ParaParty/docker-php-caddy) for the inspiration.
Lightweight, Alpine based [phpBB](https://www.phpbb.com/) docker image.
# Supported tags and respective `Dockerfile` links
- [`3.3`, `3.3.11`, `latest`](https://github.com/fat0troll/docker-phpbb/blob/master/Dockerfile) bundled with PHP 8
- [`3.3`, `3.3.4`, `latest`](https://github.com/selim13/docker-phpbb/blob/master/Dockerfile) bundled with PHP 8
- [`3.2`, `3.2.11`](https://github.com/selim13/docker-phpbb/blob/3.2-alpine-apache/Dockerfile) bundled with PHP 7.2
# How to use this image
@ -20,7 +16,7 @@ installer script, just run a temporary container with `PHPBB_INSTALL=true`
environment variable:
```console
$ docker run -p 8000:8181 --name phpbb-install -e PHPBB_INSTALL=true -d fat0troll/phpbb:3.3
$ docker run -p 8000:80 --name phpbb-install -e PHPBB_INSTALL=true -d selim13/phpbb:3.3
```
Point your browser to the http://localhost:8000 to begin the
@ -45,8 +41,9 @@ $ docker stop phpbb-install
You can start a container as follows:
```console
$ docker run --name phpbb -d fat0troll/phpbb:3.3
$ docker run --name phpbb -d selim13/phpbb:3.3
```
By default, it uses SQLite3 as a database backend, so you will need to supply
@ -55,7 +52,7 @@ it with a database file. It's default path is `/phpbb/sqlite/sqlite.db`.
You can import it from the temporary installation container above:
```console
$ docker run --volumes-from phpbb-install --name phpbb -d fat0troll/phpbb:3.3
$ docker run --volumes-from phpbb-install --name phpbb -d selim13/phpbb:3.3
```
Or just copy it inside container if you have one from previous phpBB
@ -84,7 +81,6 @@ This image utilises environment variables for basic configuration. Most of
them are passed directly to phpBB's `config.php` or to the startup script.
### PHPBB_INSTALL
If set to `true`, container will start with an empty `config.php` file and
phpBB `/install/` directory intact. This will allow you to initilalize
a forum database upon fresh installation.
@ -92,7 +88,6 @@ a forum database upon fresh installation.
### PHPBB_DB_DRIVER
Selects a database driver. phpBB3 ships with following drivers:
- `mssql` - MS SQL Server
- `mysql` - MySQL via outdated php extension
- `mysqli` - MySQL via newer php extension
@ -137,7 +132,7 @@ or by extending this image.
Table prefix for phpBB3 database.
Default value: phpbb\_
Default value: phpbb_
### PHPBB_DB_AUTOMIGRATE
@ -147,7 +142,6 @@ executing `bin/phpbbcli.php db:migrate` on every startup.
If migrations fail, container will refuse to start.
### PHPBB_DB_WAIT
If set to `true`, container will wait for database service to become available.
You will need to explicitly set `PHPBB_DB_HOST` and `PHPBB_DB_PORT` for this
to work.
@ -171,7 +165,6 @@ If set to `true`, enables phpBB debug mode.
## Volumes
By default there are four volumes created for each container:
- /phpbb/sqlite
- /phpbb/www/files
- /phpbb/www/store

9
apache2/conf.d/mpm.conf Normal file
View File

@ -0,0 +1,9 @@
PidFile "/run/apache2/httpd.pid"
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 250
MaxConnectionsPerChild 0
</IfModule>

155
apache2/httpd.conf Normal file
View File

@ -0,0 +1,155 @@
ServerTokens Prod
ServerRoot /var/www
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule allowmethods_module modules/mod_allowmethods.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule macro_module modules/mod_macro.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule echo_module modules/mod_echo.so
#LoadModule buffer_module modules/mod_buffer.so
#LoadModule data_module modules/mod_data.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule request_module modules/mod_request.so
#LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule dialup_module modules/mod_dialup.so
#LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module modules/mod_mpm_worker.so
LoadModule unixd_module modules/mod_unixd.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
LoadModule status_module modules/mod_status.so
#LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule info_module modules/mod_info.so
#LoadModule suexec_module modules/mod_suexec.so
<IfModule !mpm_prefork_module>
#LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
#LoadModule cgi_module modules/mod_cgi.so
</IfModule>
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule negotiation_module modules/mod_negotiation.so
<IfModule unixd_module>
User apache
Group apache
</IfModule>
ServerAdmin you@example.com
ServerSignature Off
#ServerName www.example.com:80
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/phpbb/www"
<Directory "/phpbb/www">
Options FollowSymLinks
AllowOverride All
Require all granted
# Return 404 for all dot files (.htaccess, .git, etc...)
RedirectMatch 404 /\..*$
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /dev/stderr
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /dev/stdout combined
</IfModule>
<IfModule mime_module>
TypesConfig /etc/apache2/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile /etc/apache2/magic
</IfModule>
IncludeOptional /etc/apache2/conf.d/*.conf

View File

@ -1,23 +0,0 @@
:8080 {
root * /var/www/html/public
php_fastcgi unix//run/php-fpm.sock {
trusted_proxies private_ranges
}
file_server
log stdout
}
:8181 {
root * /phpbb/www
php_fastcgi unix//run/php-fpm.sock {
trusted_proxies private_ranges
}
file_server
log stdout
}

View File

@ -1,56 +0,0 @@
[global]
; Log to stderr
error_log = /dev/stderr
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/php-fpm.sock
; Enable status page
pm.status_path = /fpm-status
; Ondemand process manager
pm = ondemand
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 100
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 1000
; Make sure the FPM workers can reach the environment variables for configuration
clear_env = no
; Catch output from PHP
catch_workers_output = yes
; Remove the 'child 10 said into stderr' prefix in the log and only show the actual message
decorate_workers_output = no
; Enable ping page to use in healthcheck
ping.path = /fpm-ping

View File

@ -1,2 +0,0 @@
[Date]
date.timezone="UTC"

View File

@ -1,24 +0,0 @@
[supervisord]
nodaemon=true
user=root
logfile=/dev/null
logfile_maxbytes=0
pidfile=/run/supervisord.pid
[program:php-fpm]
command=php-fpm84 -F -R
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=false
startretries=0
[program:caddy]
command=caddy run --config /etc/caddy/Caddyfile
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=false
startretries=0

View File

@ -1,12 +0,0 @@
version: '3.5'
services:
app:
image: ${IMAGE_NAME}:${IMAGE_TAG}
build: .
sut:
image: alpine:3.13
depends_on:
- app
command: /tmp/run_tests.sh
volumes:
- "./run_tests.sh:/tmp/run_tests.sh:ro"

8
php/conf.d/opcache.ini Normal file
View File

@ -0,0 +1,8 @@
opcache.memory_consumption=64
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.validate_timestamps=0
opcache.revalidate_freq=0
opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.file_cache=/phpbb/opcache

2
php/php-cli.ini Normal file
View File

@ -0,0 +1,2 @@
[php]
memory_limit = -1

18
php/php.ini Normal file
View File

@ -0,0 +1,18 @@
[PHP]
file_uploads = On
max_file_uploads = 2
upload_max_filesize = 8M
post_max_size = 8M
allow_url_fopen = On
expose_php = Off
security.limit_extensions = .php
output_buffering = On
display_errors = Off
log_errors = On
error_log = /dev/stderr
[Date]
date.timezone = 'UTC'

View File

@ -1,3 +0,0 @@
#!/usr/bin/env sh
apk --no-cache add curl
curl --silent --fail http://app:8080 | grep 'PHP 8.1'

View File

@ -1,2 +0,0 @@
<?php
phpinfo();

View File

@ -1 +0,0 @@
This static HTML file is served by Caddy

View File

@ -17,8 +17,11 @@ db_wait() {
db_migrate() {
if [[ "${PHPBB_DB_AUTOMIGRATE}" = "true" && "${PHPBB_INSTALL}" != "true" ]]; then
echo "$(date) - applying migrations"
php84 bin/phpbbcli.php db:migrate
su-exec apache php bin/phpbbcli.php db:migrate
fi
}
db_wait && db_migrate && exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
# Apache gets grumpy about PID files pre-existing
rm -f /run/apache2/httpd.pid
db_wait && db_migrate && exec httpd -DFOREGROUND "$@"