Sign inSign up

rocit/php

By rocit

•Updated about 1 year ago

Image
1

5.5K

rocit/php repository overview

⁠How to use it

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
  • in your 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

⁠ARG

NameValuesDefaultComments
ENABLE_BLACKFIREtrue,falsefalse
ENABLE_NEWRELICtrue,falsefalse
ENABLE_XDEBUGtrue,falsefalse
XDEBUG_VERSION''''Allows you to override the xdebug version installed. (don't forget to prefix with -)
APP_USER_ID''33Allows you to change the id of the www-data user inside the container to fix local permissions issues.

⁠ENV

NameValuesDefaultComments
PHP_ENV{any}, 'dev''dev'If 'dev' then php.ini settings will not apply optimizations.
SYMFONY_ENABLEDtrue,falsefalseIf 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_FOLDERAny valid path'/var/www/bin/entrypoint.d'Folder in which you can add custom scripts at the Entrypoint level. See below⁠.

⁠Volumes

  • /var/www/html - Project files
  • ${SCRIPTS_FOLDER} (default to : /var/www/bin/entrypoint.d) - Script files executed during entrypoint
  • /var/www/.composer - Composer files

⁠Purge opcache

See cachetool⁠.

$ cachetool opcache:reset

⁠Add scripts to entrypoint

# ./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.

Tag summary

Content type

Image

Digest

sha256:4d68ee13a…

Size

190.7 MB

Last updated

about 1 year ago

docker pull rocit/php:8.3