Sign inSign up

croneu/phpapp-fpm

By croneu

•Updated 5 months ago

cron PHP application docker images - PHP - PHP-FPM

Image
0

6.2K

croneu/phpapp-fpm repository overview

⁠cron PHP application docker images - PHP

⁠Abstract

Part of the docker-phpapp image suite.

Opinionated docker images for running PHP-Applications used at cron IT GmbH - mostly for TYPO3 and Neos projects but generic for any PHP application.

Images for amd64 and arm64 (i.e. they also run on Apple M1).

Born out of the desire to have good (and simple) multiplatform images for our developers to work on our PHP projects (also on M1 / ARM machines) locally and to run these same images on container platforms (mostly AWS ECS) in production.

Main goals:

  • Production-ready - run same images for local development and in production
  • As near as possible to the official images
  • Configuration through environment variables
  • Using best practices which proved good with our PHP projects in the last years

⁠Docker Images

In this repo:

  • croneu/phpapp-fpm
  • croneu/phpapp-ssh

Related:

⁠PHP-FPM (image croneu/phpapp-fpm)

Available tags:

  • croneu/phpapp-fpm:php-8.4
  • croneu/phpapp-fpm:php-8.3
  • croneu/phpapp-fpm:php-8.2
  • croneu/phpapp-fpm:php-8.1
  • croneu/phpapp-fpm:php-7.4 - no longer updated
  • croneu/phpapp-fpm:php-7.3 - no longer updated
  • croneu/phpapp-fpm:php-7.2 - no longer updated
  • croneu/phpapp-fpm:php-7.0 - no longer updated

PHP runs as PHP-FPM (image croneu/phpapp-fpm), based on the offical images. Use the croneu/phpapp-web container to be able to access this from a browser.

This image includes the following additional extensions:

  • apcu
  • bcmath
  • bz2
  • calendar
  • exif
  • ffi
  • gd
  • gettext
  • igbinary
  • imagick
  • intl
  • ldap
  • mcrypt (no longer with PHP 8.4 - long deprecated)
  • mysqli
  • opcache
  • pcntl
  • pdo_mysql
  • redis
  • shmop
  • soap
  • sockets
  • sysvmsg
  • sysvsem
  • sysvshm
  • uuid
  • vips
  • xdebug
  • yaml
  • zip

All extensions are enabled by default. If you want to only disable some of them, you can use the setting PHP_DISABLE_EXTENSIONS in the environment variables. If you want to override the list of enabled extensions, you can use the PHP_EXTENSIONS environment variable.

Additionally, the image includes the following utilities for TYPO3 specific workflows:

  • GraphicsMagick
  • curl
  • exiftool
  • ghostscript (for PDF processing with GraphicsMagick)
  • locales-all
  • poppler-utils (for pdftotext etc)
⁠SSH image (image croneu/phpapp-ssh)

Available tags:

  • croneu/phpapp-ssh:php-8.4-node-22
  • croneu/phpapp-ssh:php-8.3-node-20
  • croneu/phpapp-ssh:php-8.2-node-18
  • croneu/phpapp-ssh:php-8.1-node-16
  • croneu/phpapp-ssh:php-7.4-node-16 - no longer updated
  • croneu/phpapp-ssh:php-7.4-node-14 - no longer updated
  • croneu/phpapp-ssh:php-7.4-node-12 - no longer updated
  • croneu/phpapp-ssh:php-7.4-node-10 - no longer updated
  • croneu/phpapp-ssh:php-7.3-node-10 - no longer updated
  • croneu/phpapp-ssh:php-7.2-node-10 - no longer updated
  • croneu/phpapp-ssh:php-7.0-node-14 - no longer updated

You can start a container for SSH'ing into it for development purposes with the image croneu/phpapp-ssh. It is based off the phpapp-fpm image (thus it contains the exact same version and extensions installed) but additionally includes a set of tools to work with the application from the command line:

  • Composer v2
  • NodeJS
  • Convenience tools: git, zip, make, ping, less, vi, wget, joe, jq, rsync, patch
  • clitools from WebdevOps
  • MySQL client
  • redis-cli
  • GraphicsMagick
  • exiftool, poppler-utils
⁠SSH image for onetime tasks

You can also use the phpapp-ssh image to run one-time containers to execute certain tasks with the same setup. I.e.:

docker run -v .:/app --rm croneu/phpapp-ssh:php-8.4-node-22 make test 

Or in docker-compose:

  test:
    image: croneu/phpapp-ssh:php-8.4-node-22
    command: make test
    volumes:
      - .:/app

⁠Usage

⁠Application root

Application root is /app. Application runs as user application (uid=1000).

⁠Settings (through environment variables)
SettingImageDefaultDescription
XDEBUG_MODEfpm, sshdebugOr set to develop (slow) or none to turn it off completely. See https://xdebug.org/docs/all_settings#mode⁠
DB_HOST, DB_USER, DB_PASS, DB_NAMEsshThese will create a .my.cnf for the user. You can use the same variables in your docker-compose.yml to configure the MariaDB image.
APPLICATION_UID, APPLICATION_GIDfpm, ssh1000, 1000UID and GID for the application user. Change to match your local user in case you use bind-mounts (Linux only)
IMPORT_GITLAB_SERVERsshgit.cron.euGitlab instance to import SSH key from
IMPORT_GITLAB_PUB_KEYSsshGitlab user to import SSH keys from
IMPORT_GITHUB_PUB_KEYSsshGitHub user to import SSH keys from
IMPORT_PUB_KEYSsshAdditional SSH public keys to load, comma separated
SSH_CONFIGsshThe whole content of the .ssh/config file
SSH_KNOWN_HOSTSsshThe whole content of the .ssh/known_hosts file
SSH_PRIVATE_KEYsshA SSH private key to load in an ssh-agent, useful if you run a SSH container with commands
ENVsshThe name of the environment to show on the shell prompt
PHP_INI_OVERRIDEfpm, sshAllow overriding php.ini settings. Simply the multiline content for a php.ini here. Use "\n" for multiline i.e. in ECS
PHP_FPM_OVERRIDEfpmAllow overriding php-fpm pool settings. The multiline content for php-fpm.conf here. Use "\n" for multiline i.e. in ECS
PHP_EXTENSIONSfpm, ssh(all)Comma separated list of PHP extensions to enable (if this is not set, all are enabled).
PHP_DISABLE_EXTENSIONSfpm, sshComma separated list of PHP extensions to disable (in case you keep all enabled, you can disable individual ones, i.e. igbinary).
PHPINI__xxx__yyyfpm, sshSet php.ini setting xxx.yyy (always lower cased)
PHPFPM__xxx__yyyfpmSet php-fpm pool setting xxx.yyy (always lower cased)

The PHPINI__... and PHPFPM__... allow to set individual settings for php.ini and php-fpm.conf (pool settings) using individual environment variables. Just replace the . in the settings by __. Examples:

Upper case allowed (will be lower-cased):

PHPINI__SESSION__SAVE_HANDLER=redis
PHPINI__SESSION__SAVE_PATH='"tcp://redis:6379?persistent=1&weight=1&database=10&prefix=PHPSESSID:"'
PHPINI__REDIS__SESSION__LOCKING_ENABLED=1

Or (lower case also fine):

PHPFPM__request_terminate_timeout=30s
PHPFPM__pm__max_children=15

Note: make sure that potentially required double quotes " are part of the "string" that ends up in the ENV variable, so quote as necessary, because this string is copied "as is" to the ini files. See example above for the PHPINI__SESSION__SAVE_PATH - this would be the syntax for a .env file.

⁠Example usage

Copy the files from example-app/ folder to your application, tweak, and you are ready to go.

⁠Web Server

The web container will start a web-server listening on the port you specified in docker-compose.yml (default is 8000 and 8443).

To access the web-server, make sure you have a DNS entry in your local /etc/hosts or local DNS server:

/etc/hosts for docker-machine:

192.168.99.100 my-app.vm

/etc/hosts for Docker for Mac or locally on Linux:

127.0.0.1 my-app.vm

Then you can access the web-server:

⁠SSH Access

You can then SSH into the container using for example:

ssh -A -p 1122 [email protected]

⁠Docker Image Development

Build is triggered automatically via Github Actions.

To create them locally for testing purposes (and load created images to your docker).

Image croneu/phpapp-ssh:php-8.4-node-22:

make build-ssh PHP_VERSION=8.4 NODE_VERSION=22 DOCKER_CACHE=

Image croneu/phpapp-fpm:php-8.4:

make build-fpm PHP_VERSION=8.4 DOCKER_CACHE=
⁠Test the Docker Image

To test the image you can use the supplied docker-compose files in the example-app directory.

⁠MIT Licence

See the LICENSE⁠ file.

⁠Author

Ernesto Baschny, cron IT GmbH⁠

Tag summary

Content type

Image

Digest

sha256:ce97968a8…

Size

315.3 MB

Last updated

5 months ago

docker pull croneu/phpapp-fpm:php-8.4