Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Docker for Symfony application 🐳

NotificationsYou must be signed in to change notification settings

kibatic/symfony-docker

Repository files navigation

symfony-docker

Symfony + Nginx + php-fpm

Build Status

Docker for Symfony application, powered byNginx andphp-fpm.

Based on Debian Jessie.

If you are experiencing some issues, take a look atTROUBLESHOOTING

Supported tags and respectiveDockerfile links

Image tags follows PHP versions

latest8.1(8.1/Dockerfile)

8.0(8.0/Dockerfile)

77.4(7.4/Dockerfile)

7.3(7.3/Dockerfile)

7.2(7.2/Dockerfile)

7.1Not maintained, END OF LIFE

7.0Not maintained, END OF LIFE

5,5.6Not maintained, END OF LIFE

5.4Not maintained, END OF LIFE

Compatibility matrix

Symfony
Image2.x3.x4.x5.x6.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

Usage

Basic Usage

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/

use of blackfire (PHP >= 8.4)

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

Custom nginx configuration

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

Logging

Logging (PHP >= 7.3)

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

Logging (PHP < 7.3)

A common practice is to log to stdout, but there are major bug in php-fpm wich makes stdout logging not reliable :

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

Minimal package included

  • nginx
  • php*-fpm
  • php*-cli
  • php*-intl
  • php*-mbstring

Exposed port

  • 80 : nginx

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp