Php fpm docker file

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

License

oneinstack/docker-php-fpm

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Available Architectures: amd64 , arm64

This repository will provide you fully functional PHP-FPM Docker images in different flavours, versions and packed with different types of integrated PHP modules. It also solves the problem of syncronizing file permissions of mounted volumes between the host and the container.

This repository also allows you to quickly generate and build your own custom PHP-FPM Docker image with whatever PHP extension your desire for whatever PHP version you want and for any platform you’re on ( amd64 or arm64 ). Jump to #Build your own image.

docker pull oneinstack/php-fpm:tag>

ℹ️ For details see Documentation: Docker Tags
ℹ️ For details see Documentation: Supported Architectures

The following PHP versions are provided by this repository.

  • PHP 5.3 , PHP 5.4 , PHP 5.5 , PHP 5.6
  • PHP 7.0 , PHP 7.1 , PHP 7.2 , PHP 7.3 , PHP 7.4
  • PHP 8.0 , PHP 8.1 , PHP 8.2

Note: Unreleased PHP versions are built from custom base images.

ℹ️ For details see Documentation: PHP Versions
ℹ️ For details see Documentation: Base Images

The provided Docker images heavily rely on inheritance to guarantee smallest possible image size. Each of them provide a working PHP-FPM server and you must decide what version works best for you. Look at the sketch below to get an overview about the two provided flavours and each of their different types.

[PHP] # Base FROM image (Official PHP-FPM image) ^ # | # | # [base] # Streamlined base images with host user mapping ^ # environment variables and custom configs. | # | # [mods] # Installs additional PHP modules ^ # via pecl, git and other means | # | # [prod] # Devilbox flavour for production # (locales, postifx, socat and injectables) # (custom *.ini files) #

ℹ️ For details see Documentation: Flavours
ℹ️ For details see Documentation: Base Images

Click below listed extensions for details:

The provided Docker images offer environment variables to alter their startup behaviour.

ℹ️ For details see Documentation: Environment Variables or click on the variable name directly.

Variable Short description
DEBUG_ENTRYPOINT Control docker log verbosity
NEW_UID Syncronize user-id file system permissions
NEW_GID Syncronize group-id file system permissions
TIMEZONE Set timezone
DOCKER_LOGS Make PHP log to file or docker logs
ENABLE_MODULES Enable specific PHP extensions
DISABLE_MODULES Disable specific PHP extensions
ENABLE_MAIL Control email-catch all (to not accidentally send out emails)
FORWARD_PORTS_TO_LOCALHOST Make remote ports available locally inside the container
MYSQL_BACKUP_USER Set MySQL username (for backups)
MYSQL_BACKUP_PASS Set MySQL password (for backups)
MYSQL_BACKUP_HOST Set MySQL hostname (for backups)

The provided Docker images offer different volumes to be mounted.

ℹ️ For details see Documentation: Volumes or click on the volume name directly.

Volume Short description
/etc/php-custom.d/ Add custom PHP *.ini files
/etc/php-fpm-custom.d/ Add custom PHP-FPM *.conf files
/startup.1.d/ Add custom startup *.sh files
/startup.2.d/ Add custom startup *.sh files
/var/log/php/ Find PHP log files
/var/mail/ Find sent emails
/etc/supervisor/custom.d/ Add custom supervisord *.conf files
/etc/bashrc-devilbox.d/ Add custom bashrc files
/shared/backups/ Find MySQL backups
/ca/ Add custom Certificate Authority

Have a look at the following table to see all offered exposed ports for each Docker image flavour.

Flavour Port Description
base
mods
prod
9000 PHP-FPM listening port

PHP Default Configuration

Each PHP version is using the same sane default php.ini values, making it pain-free to switch versions and not having to worry about different php.ini settings. Note: Flavours alway inherit the settings from its parent flavour if they have no own configuration.

Flavour Applied php.ini files
base php.ini and php-fpm.conf
mods inherits from base
prod inherits from base
slim php.ini and php-fpm.conf
work inherits from slim

Apart from the provided tools, you will also be able to use the container similar as you would do with your host system. Just a few things to mention here:

  • Mount custom bash configuration files so your config persists between restarts
  • Use password-less sudo to become root and do whatever you need to do

Provide PHP-FPM port to host

docker run -d -it \ -p 127.0.0.1:9000:9000 \ oneinstack/php-fpm:7.2-prod

Alter PHP-FPM and system timezone

docker run -d -it \ -p 127.0.0.1:9000:9000 \ -e TIMEZONE=Europe/Berlin \ oneinstack/php-fpm:7.2-prod

Load custom PHP configuration

config/ is a local directory that will hold the PHP *.ini files you want to load into the Docker container.

# Create config directory to be mounted with dummy configuration mkdir config # Xdebug 2 echo "xdebug.enable = 1" > config/xdebug.ini # Xdebug 3 echo "xdebug.mode = debug" > config/xdebug.ini # Run container and mount it docker run -d -it \ -p 127.0.0.1:9000:9000 \ -v config:/etc/php-custom.d \ oneinstack/php-fpm:7.2-prod

MySQL connect via 127.0.0.1 (via port-forward)

Forward MySQL Port from 172.168.0.30 (or any other IP address/hostname) and Port 3306 to the PHP docker on 127.0.0.1:3306 . By this, your PHP files inside the docker can use 127.0.0.1 to connect to a MySQL database.

docker run -d -it \ -p 127.0.0.1:9000:9000 \ -e FORWARD_PORTS_TO_LOCALHOST='3306:172.168.0.30:3306' \ oneinstack/php-fpm:7.2-prod

MySQL and Redis connect via 127.0.0.1 (via port-forward)

Forward MySQL Port from 172.168.0.30:3306 and Redis port from redis:6379 to the PHP docker on 127.0.0.1:3306 and 127.0.0.1:6379 . By this, your PHP files inside the docker can use 127.0.0.1 to connect to a MySQL or Redis database.

docker run -d -it \ -p 127.0.0.1:9000:9000 \ -e FORWARD_PORTS_TO_LOCALHOST='3306:172.168.0.30:3306, 6379:redis:6379' \ oneinstack/php-fpm:7.2-prod

Launch Postfix for mail-catching

Once you set $ENABLE_MAIL=2 , all mails sent via any of your PHP applications no matter to which domain, are catched locally into the devilbox account. You can also mount the mail directory locally to hook in with mutt and read those mails.

docker run -d -it \ -p 127.0.0.1:9000:9000 \ -v /tmp/mail:/var/mail \ -e ENABLE_MAIL=2 \ oneinstack/php-fpm:7.2-prod

~/my-host-www will be the directory that serves the php files (your document root). Make sure to mount it into both, php and the webserver.

# Start PHP-FPM container docker run -d -it \ -v ~/my-host-www:/var/www/default/htdocs \ --name php \ oneinstack/php-fpm:7.2-prod # Start webserver and link with PHP-FPM docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default/htdocs \ -e PHP_FPM_ENABLE=1 \ -e PHP_FPM_SERVER_ADDR=php \ -e PHP_FPM_SERVER_PORT=9000 \ --link php \ oneinstack/nginx-mainline

Docker Compose reference implementation

Docker images are built and tested every night by GitHub Actions and pushed to Docker hub on success. This is all done automatically to ensure that sources as well as base images are always fresh and in case of security updates always have the latest patches.

You are not interested in the provided Docker images and want to (ab)use this repository purely to generate your own custom images? You can do so with three easy commands:

# Generate Dockerfiles with only the following PHP extensions present make gen-dockerfiles MODS="msgpack memcached pdo_mysql rdkafka" # Pull base image for PHP 8.1 (if you don't have it locally already) make docker-pull-base-image STAGE=mods VERSION=8.1 ARCH=linux/arm64 # Build PHP 8.1 for arm64 with above specified extensions make build STAGE=mods VERSION=8.1 ARCH=linux/arm64

Contributors are welcome. Feel free to star and clone this repository and submit issues and pull-requests. Add examples and show what you have created with the provided images. If you see any errors or ways to improve this repository in any way, please do so.

Источник

Читайте также:  Python setting path variable
Оцените статью