Base php-fpm image for running Roadiz app, cron-jobs and workers.
766
Base php-fpm image for running Roadiz app, cron-jobs and workers.
This image does not provide Nginx server, but it includes dcron and many image processing binaries.
It listens on port 9000 and is meant to be used with a separate Nginx container.
Make sure to use a .dockerignore at your project root not to include any existing
cache files or build-time vendors (node_modules).
Before building your project Docker image make sure to prepare your project sources:
composer install -o.dockerignoreThis image is designed to run only one process at a time. If your project needs to run cron jobs or workers (Symfony Messenger), you should use a separate container for each process and override container entrypoint (only main app container should launch docker-php-entrypoint).
Create a docker/php-fpm-alpine/Dockerfile file in your Roadiz / Symfony project.
You can customize the image by overriding the following files:
docker/php-fpm-alpine/php.prod.inidocker/php-fpm-alpine/crontab.txtdocker/php-fpm-alpine/docker-php-entrypoint# File: docker/php-fpm-alpine/Dockerfile
FROM roadiz/php81-fpm-alpine:latest
MAINTAINER Ambroise Maupate <[email protected]>
ARG USER_UID=1000
RUN usermod -u ${USER_UID} www-data \
&& groupmod -g ${USER_UID} www-data
# Copy custom configuration files
COPY docker/php-fpm-alpine/php.prod.ini /usr/local/etc/php/php.ini
COPY docker/php-fpm-alpine/crontab.txt /crontab.txt
COPY docker/php-fpm-alpine/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint
# Copy your project files
COPY --chown=www-data:www-data . /var/www/html/
RUN ln -s /var/www/html/bin/console /usr/local/bin/console \
&& /usr/bin/crontab -u www-data /crontab.txt \
&& chmod +x /usr/local/bin/docker-php-entrypoint \
&& chown -R www-data:www-data /var/www/html/
# Define persistent data volumes directories
VOLUME /var/www/html/config/jwt \
/var/www/html/public/files \
/var/www/html/public/assets \
/var/www/html/var/files \
/var/www/html/config/secret
php-fpmapp:
build:
dockerfile: ./docker/php-fpm-alpine
context: .
args:
USER_UID: ${USER_UID}
restart: always
depends_on:
- db
- redis
volumes:
# Provide named volumes for persistent data
- app_jwt_data:/var/www/html/config/jwt
- app_file_data:/var/www/html/public/files
- app_assets_data:/var/www/html/public/assets
- app_private_file_data:/var/www/html/var/files
- app_secret_data:/var/www/html/config/secrets
networks:
- default
environment:
APP_ENV: ${APP_ENV}
APP_RUNTIME_ENV: ${APP_RUNTIME_ENV}
APP_DEBUG: ${APP_DEBUG}
crontab support for scheduled tasks by overriding container entrypoint:cron:
extends: app
# https://github.com/dubiousjim/dcron/issues/13#issuecomment-1406937781
init: true
entrypoint: [ "crond", "-f", "-L", "15" ]
restart: always
worker:
extends: app
deploy:
replicas: 1
entrypoint: [ "php", "/var/www/html/bin/console", "messenger:consume", "async", "--time-limit=1800" ]
restart: always
Content type
Image
Digest
sha256:e2efe82d9…
Size
292.8 MB
Last updated
almost 2 years ago
docker pull roadiz/php81-fpm-alpine