Skip to content

Contains php docker image example for use with eZ Platform (and implicit eZ Platform EE & Symfony)

License

Notifications You must be signed in to change notification settings

ezsystems/docker-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of PHP Docker image for use with eZ Platform

Example/Internal: Instructions and Tools in this repository is provided as an example, which you can take and customize to your needs if you want to. This is something we use activly internally for QA and Demo use, and thus might change without notice (we version the images, but only latests version receives updates).

If you are looking to have a ready made Docker environment for local development see eZ Launchpad which is supported/provided by the comunity.

If you are looking for ready made, optimized, development and production hosted environment see eZ Platform Cloud

This Git repository contains source code for eZ Systems provided Docker PHP images available on Docker Hub.

The Docker images here extends official PHP images and includes php-cli, php-fpm, composer, blackfire, tweaks and extensions for optimal use with any advance Symfony applications (like eZ Platform and eZ Platform EE).

NOTE: The images here, just like the official once they extend, are meant to follow Dockers 1 main process per container recommendation from Docker, adding additional services to the image is not recommended and probably won't work. If so start from scratch with something else instead of using this.

Overview

PHP image that aims to technically support running:

  • eZ Platform/Platform Enterprise (1.13.4 or higher)
  • Symfony (As in any symfony-standard like app that have same or less requirements then eZ Platform)

The v1 format images are meant for eZ Platform v1, for images that can be used with eZ Platform v2 and v3 look at the v2 format.

Images

This repository contains several images for different versions of PHP*:

  • Extends php:x.y-fpm (uses debian:stretch-slim unless otherwise noted):
    • 7.4 (uses debian:buster-slim)
    • 7.3
    • 7.2 (Security fixes only)
    • 7.1 (End of life December 2019, move to newer or use LTS packages from a Linux distro instead)
    • 7.0 (End of life January 2019, move to newer or use LTS packages from a Linux distro instead)
    • 5.6 (End of life December 2018, move to newer or use LTS packages from a Linux distro instead)

Recommended version for testing newest versions of eZ Platform is PHP 7.3 or 7.4 for best performance.

* Primarily: Since this is also used to run functional testing against several PHP versions, for any other usage use the recommended image.

Node image

For each php version there is an additional -node flavour with Node.js (Node 10 LTS) and Yarn installed, useful if your project needs it (for example for Webpack Encore).

Dev image

For each php version there is an additional -dev flavour based on Node image, with additional tools for when you need to be able to login and work towards the installation. It contains tools like vim, git, xdebug, ... and others.

Tip: To customize Xdebug configuration you can use XDEBUG_CONFIG environment variable, check Using an environment variable section in Xdebug documentation.

Format version

To be able to improve the image in the future, we have added a format version number that we will increase on future changes (for instance move to Alpine Linux).

It is recommended to specify a tag with this format version number in your Docker / docker-compose use to avoid breaks in your application.

Usage

This image has been made so it can be used directly for development and built with your application for production use, this allows you to use the same image across all whole DevOps life cycle (dev, build, testing, staging and production).

Before you start, you can test the image to see if you get which php version it is running:

docker run --rm ezsystems/php:7.2 php -v

This should result in something like:

PHP 7.2.8 (cli) (built: Jul 21 2018 07:56:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.22.0~linux-x64-non_zts72, https://blackfire.io, by Blackfire

Production use

In your application folder, you'll need to add a Dockerfile where you customize it, including adding your application. For example see for instance Dockerfile in ezsystems/ezplatform.

Then for building it you can for instance execute:

docker build -t mycompany/myapp_volume:latest .

And by now you can execute some (see below to attach database, ..) commands to test it:

docker run --rm mycompany/myapp_volume bin/console list

Development use

Warning: As of December 2016, avoid using Docker for Mac/Windows beta for this setup, as it's load times are typically 60-90 seconds because of IO issues way worse then what Virtualbox ever had when doing shared folder. Which is essentially what is being used here when not on Linux, and when using what Docker calls host mounted volumes.

To get started, lets set permissions for dev use (Symfony 3.x structure reflected in example), and make sure to install composer packages:

sudo mkdir -p web/var
sudo find web/var var -type d | xargs sudo chmod -R 777
sudo find web/var var -type f | xargs sudo chmod -R 666
docker run --rm -u www-data -v `pwd`:/var/www -e SYMFONY_ENV=dev ezsystems/php:7.2 composer install --no-progress --no-interaction --prefer-dist

Now you can run some (see below to attach database, ..) commands to test it:

docker run --rm -u www-data -v `pwd`:/var/www -e SYMFONY_ENV=dev ezsystems/php:7.2 bin/console list

Use with full setup (database, ..)

For setting up a full setup with database and so on, see ezplatform:doc/docker for further examples and instructions.

Possible roadmap for this PHP image

  • PHP plugins:
  • pdo_pgsql + pdo_sqlite
  • env variable to set session handler, ...
  • Apache + mod_php variant
  • Alpine Linux; To drop image size, assuming all other official images move to Alpine.

Copyright & license

Copyright eZ Systems AS, for copyright and license details see provided LICENSE file.

About

Contains php docker image example for use with eZ Platform (and implicit eZ Platform EE & Symfony)

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published