- Notifications
You must be signed in to change notification settings - Fork8
kibatic/symfony-docker
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Docker for Symfony application, powered byNginx andphp-fpm.
Based on Debian Jessie.
If you are experiencing some issues, take a look atTROUBLESHOOTING
Image tags follows PHP versions
latest
8.1
(8.1/Dockerfile)
7
7.4
(7.4/Dockerfile)
7.1
Not maintained, END OF LIFE
7.0
Not maintained, END OF LIFE
5
,5.6
Not maintained, END OF LIFE
5.4
Not maintained, END OF LIFE
Symfony | ||||||
---|---|---|---|---|---|---|
Image | 2.x | 3.x | 4.x | 5.x | 6.x | |
8.1 | ❌ | ❌ | ✔️ (not tested) | ✔️ (not tested) | ✔️ (not tested) | |
8.0 | ❌ | ❌ | ✔️ (not tested) | ✔️ (default) | ✔️ (not tested) | |
7.4 | ❌ | ❌ | ✔️ | ✔️ (default) | ❌ | |
7.3 | ✔️ (not tested) | ✔️ (not tested) | ✔️ (default) | ✔️ (not tested) | ❌ | |
7.2 | ✔️ (not tested) | ✔️ | ✔️ | ✔️ (not tested) | ❌ | |
7.1 | ✔️ (not tested) | ✔️ | ✔️ | ❌ | ❌ | |
7.0 | ✔️ (not tested) | ✔️ (not tested) | ❌ | ❌ | ❌ | |
5.6 | ✔️ (not tested) | ✔️ (not tested) | ❌ | ❌ | ❌ |
Composer versions :
- 8.0+ : 2.x
- 7.4 : 2.x
- 7.3 : 1.10.17
- 7.2 : 1.10.17
docker pull kibatic/symfony
Then run in your symfony folder
# Image >= 7.3 & Symfony 2.x, 3.xdocker run -e SYMFONY_VERSION=3 -v$(pwd):/var/www -p 8080:80 kibatic/symfony:7.3# Image >= 7.3 & Symfony 4.xdocker run -v$(pwd):/var/www -p 8080:80 kibatic/symfony:7.3# Image < 7.3 & Symfony 2.x, 3.xdocker run -v$(pwd):/var/www -p 8080:80 kibatic/symfony:7.2# Image < 7.3 & Symfony 4.xdocker run -e SYMFONY_VERSION=4 -v$(pwd):/var/www -p 8080:80 kibatic/symfony:7.2
Symfony app will be accessible onhttp://localhost:8080/
Add the following vars in the docker-compose file :
web:build:.volumes: -.:/var/wwwenvironment:PERFORMANCE_OPTIM:"false"BLACKFIRE_SERVER_ID:3xxxx-xxxxx-xxxxxx-xxxxxxx-xxcBLACKFIRE_SERVER_TOKEN:5d6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc47fbBLACKFIRE_CLIENT_ID:8exxxxx-xxx-xxxxx-xxxxxx-xx5BLACKFIRE_CLIENT_TOKEN:6caaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx012
Then to enable or disalble blackfire :
# enable blackfiredocker composeexec -T web /enable-blackfire.sh --on# disable blackfiredocker composeexec -T web /enable-blackfire.sh --off
In our project, we use a Makefile to simplify the commands (from the container or from the host) :
_enable-blackfire:## enable blackfire/enable-blackfire.sh --onenable-blackfire:## enable blackfiredocker composeexec -T web make _enable-blackfire_disable-blackfire:## disable blackfire/enable-blackfire.sh --offdisable-blackfire:## disable blackfiredocker composeexec -T web make _disable-blackfire
If you want to replace the default nginx settings, overwrite configuration file at/etc/nginx/sites-enabled/default
.
COPY nginx.conf /etc/nginx/sites-enabled/default
You may also want to add only some directives inexisting site config.
COPY custom-config.conf /etc/nginx/conf.d/docker/custom-config.conf
For both production and dev environment you should log to stdout / stderr, example below.
# config/packages/monolog.yamlmonolog:handlers:stdout:type:streampath:'php://stdout'level:debugchannels:['!event']# (Optional) format logs to json#formatter: monolog.formatter.jsonstderr:type:streampath:'php://stderr'level:error# (Optional) format logs to json#formatter: monolog.formatter.json
A common practice is to log to stdout, but there are major bug in php-fpm wich makes stdout logging not reliable :
- Logs are truncated when message length exceed 1024https://bugs.php.net/bug.php?id=69031
- FPM prepend a warning string to worker outputhttps://bugs.php.net/bug.php?id=71880
This image setup a known workaround (see here) and expose a log stream as env varLOG_STREAM, butyou cannot log to stdoutFor a proper logging you have to configure monolog to log to this stream
# app/config_dev.ymlmonolog:handlers:main:type:streampath:'/tmp/stdout'level:debug
You can also use symfony%env(LOG_STREAM)%
if your symfony version is compatible withthis syntax
We also provide a default dirty solution for standard monolog configuration,this is not recommended in production
tail -q -n 0 -F app/logs/dev.log app/logs/prod.log var/logs/dev.log var/logs/prod.log
- nginx
- php*-fpm
- php*-cli
- php*-intl
- php*-mbstring
- 80 : nginx