Just use separate PHP container for CLI ops. Works fine. From my point of view it is enough to provide Dockerfiles and docker-compose.yml. No need for public pre-builded images. Let this battle-tested code for 300k posts be an inspiration.
- Example of maintenance operations
sudo docker run --rm -it --network flarum_default -v /opt/flarum/data/web:/data/web php8.1-cli-flarum bash
cd /data/web
php flarum info
composer show
- Dockerfile.php8.1-cli-flarum (This one is for the maintenance operations)
# docker build -t php8.1-cli-flarum -f ./Dockerfile.php8.1-cli-flarum .
FROM php:8.1-cli
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions curl dom fileinfo gd json mbstring openssl pdo_mysql tokenizer zip @composer-2
- Dockerfile.php8.1-fpm-flarum
# docker build -t php8.1-fpm-flarum -f ./Dockerfile.php8.1-fpm-flarum .
FROM php:8.1-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions curl dom fileinfo gd json mbstring openssl pdo_mysql tokenizer zip
- docker-compose.yml for simple deployment (no queue workers, no scheduler, no Redis)
version: "3"
services:
caddy:
image: caddy:2-alpine
restart: always
depends_on:
- php-fpm
- mysql
ports:
- "127.0.0.1:3000:3000"
volumes:
- ./config/caddy.conf:/etc/caddy/Caddyfile
- ./data/web:/data/web
- ./data/log:/var/log/caddy/
php-fpm:
image: php8.1-fpm-flarum
restart: always
deploy:
replicas: 10
volumes:
- ./data/web:/data/web
- ./config/php.ini:/usr/local/etc/php/php.ini
mysql:
image: mysql:8.0
restart: always
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--default-authentication-plugin=mysql_native_password', '--log_error_verbosity=1']
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ./data/database:/var/lib/mysql
+ reverse (TLS) proxy server of your choice, for example Caddy again.