You must extend it (because of ONBUILD instructions).
# ./docker/php/Dockerfile
FROM rocit/php:8.0-alpine as php
USER root
ARG APP_USER_ID=33
# Recommended to fix permission issues
RUN usermod -u ${APP_USER_ID} www-data; \
groupmod -g ${APP_USER_ID} www-data;
USER www-data
#---------------
# Composer
#---------------
FROM php as phptools
COPY --chown=www-data:www-data --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN composer self-update
# ./php.env
PHP_XDEBUG_ENABLED=1
XDEBUG_CONFIG=remote_host=172.28.0.4 remote_port=30093
docker-compose.yaml# ./docker-compose.yaml
version: '3.7'
services:
php:
image: 'rocit/php:myapp-php'
build:
context: './docker/php'
target: 'php'
args:
ENABLE_BLACKFIRE: 'true'
ENABLE_XDEBUG: 'true'
ENABLE_CRON: 'false'
APP_USER_ID: '${APP_USER_ID:?}'
env_file:
- './php.env'
tty: true
phptools:
image: 'rocit/php:myapp-phptools'
build:
context: './docker/php'
target: 'phptools'
args:
ENABLE_BLACKFIRE: 'false'
ENABLE_XDEBUG: 'false'
ENABLE_CRON: 'false'
APP_USER_ID: '${APP_USER_ID:?}'
env_file:
- './php.env'
tty: true
$ cat >> ./.env << EOF
# Fix permissions issues
APP_USER_ID=$(id -u)
EOF
| Name | Values | Default | Comments |
|---|---|---|---|
ENABLE_BLACKFIRE | true,false | false | |
ENABLE_NEWRELIC | true,false | false | |
ENABLE_XDEBUG | true,false | false | |
XDEBUG_VERSION | '' | '' | Allows you to override the xdebug version installed. (don't forget to prefix with -) |
APP_USER_ID | '' | 33 | Allows you to change the id of the www-data user inside the container to fix local permissions issues. |
| Name | Values | Default | Comments |
|---|---|---|---|
PHP_ENV | {any}, 'dev' | 'dev' | If 'dev' then php.ini settings will not apply optimizations. |
SYMFONY_ENABLED | true,false | false | If true then php.ini will apply some optimization for Symfony. If combined with PHP_ENV=prod it will also enable preload (:warning: symfony version). |
SCRIPTS_FOLDER | Any valid path | '/var/www/bin/entrypoint.d' | Folder in which you can add custom scripts at the Entrypoint level. See below. |
/var/www/html - Project files${SCRIPTS_FOLDER} (default to : /var/www/bin/entrypoint.d) - Script files executed during entrypoint/var/www/.composer - Composer filesSee cachetool.
$ cachetool opcache:reset
# ./php/Dockerfile
ARG PHP_VERSION=8.0-alpine
FROM rocit/php:${PHP_VERSION} as base_php
COPY ./scripts/ $SCRIPTS_FOLDER/
# ...
With ./scripts that could be of any structure you want. :warning: Only .sh files will be executed.
A good tip is to name your files aa-first-thing-to-do.sh, ..., zz-last-thing-to-do.sh.
FPM will only be started after all those scripts.
Content type
Image
Digest
sha256:4d68ee13a…
Size
190.7 MB
Last updated
about 1 year ago
docker pull rocit/php:8.3