Skip to content

Run a Symfony application using Docker & docker-compose

License

Notifications You must be signed in to change notification settings

fpondepeyre/docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker

This is a complete stack for running Symfony 4 (latest version: Flex) into Docker containers using docker-compose tool.

Installation

First, clone this repository:

$ git clone git@github.com:fpondepeyre/docker.git

Next, put your Symfony application into symfony folder and do not forget to add symfony.localhost in your /etc/hosts file.

Make sure you adjust database_host in parameters.yml to the database container alias "db"

Then, run:

$ docker-compose up

You are done, you can visit your Symfony application on the following URL: http://symfony.localhost (and access Kibana on http://symfony.localhost:81 and Rabbitmq on http://symfony.localhost:8080)

Note : you can rebuild all Docker images by running:

$ docker-compose build

How it works?

Here are the docker-compose built images:

  • db: This is the MySQL database container (can be changed to postgresql or whatever in docker-compose.yml file),
  • php: This is the PHP-FPM container including the application volume mounted on,
  • nginx: This is the Nginx webserver container in which php volumes are mounted too,
  • elk: This is a ELK stack container which uses Logstash to collect logs, send them into Elasticsearch and visualize them with Kibana.
  • rabbitmq: This is a message broker container.

This results in the following running containers:

> $ docker-compose ps
        Name                       Command         State              Ports
----------------------------------------------------------------------------------------------------------------------------------------------------
docker_db_1       docker-entrypoint.sh mysqld      Up      0.0.0.0:3306->3306/tcp
docker_elk_1      /usr/bin/supervisord -n -c ...   Up      0.0.0.0:81->80/tcp
docker_nginx_1    nginx                            Up      443/tcp, 0.0.0.0:80->80/tcp
docker_php_1      php-fpm7 -F                      Up      0.0.0.0:9000->9000/tcp
docker_rabbitmq_1 docker-entrypoint.sh rabbi ...   Up      15671/tcp, 0.0.0.0:8080->15672/tcp, 25672/tcp, 4369/tcp, 5671/tcp, 0.0.0.0:5682->5672/tcp

Read logs

You can access Nginx and Symfony application logs in the following directories on your host machine:

  • logs/nginx
  • logs/symfony

Use Kibana!

You can also use Kibana to visualize Nginx & Symfony logs by visiting http://symfony.localhost:81.

Code license

You are free to use the code in this repository under the terms of the 0-clause BSD license. LICENSE contains a copy of this license.

Releases

No releases published

Packages

No packages published

Languages