This is a complete stack for running Symfony 5.2 into Docker containers using docker-compose tool.
-
Clone this repository:
$ git clone https://github.com/hounaida/manage-books.git
-
Add
symfony.localhost
in your/etc/hosts
file. -
Make sure you adjust
DATABASE_URL
insymfony/.env
file. -
Run containers
$ docker-compose up -d
Note : you can rebuild all Docker images by running:
$ docker-compose build
Here are the docker-compose
built images:
db
: This is the MySQL database container (can be changed to postgresql or whatever indocker-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,redis
: This is the Redis container.
This results in the following running containers:
> $ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------
docker-symfony_db_1 docker-entrypoint.sh Up 0.0.0.0:3306->3306/tcp
--def ... , 33060/tcp
docker-symfony_nginx_1 nginx Up 443/tcp,
0.0.0.0:80->80/tcp
docker-symfony_php_1 php-fpm7 -F Up 0.0.0.0:9000->9001/tcp
docker- /docker-entrypoint.sh Up 0.0.0.0:8080->80/tcp
symfony_phpmyadmin_1 apac ...
docker-symfony_redis_1 docker-entrypoint.sh Up 0.0.0.0:6379->6379/tcp
redis ...
$ docker exec -it docker-symfony_php_1 /bin/sh
$ composer install
You are done, you can visit your Symfony application on the following URL: http:https://symfony.localhost
.
$ bin/console doctrine:migrations:migrate
$ bin/console doctrine:fixtures:load
$ bin/phpunit
login symfony.localhost/login
login: hounaida
password: houanida
$ docker exec -it docker-symfony_redis_1 /bin/sh
$ redis-cli
$ keys *
You can access Nginx and Symfony application logs in the following directories on your host machine:
logs/nginx
logs/symfony