Docker stack for Symfony
MIT License
Complete Docker stack for Symfony with NGINX, PHP, MySQL, MinIO, MailHog, Redis, RabbitMQ and Elasticsearch using docker-compose tool.
+---------+-----------+---------+---------+-----------+---------+----------+-----------------+
| | | | | | | | |
| NGINX | PHP-FPM | MySQL | MinIO | MailHog | Redis | RabbitMQ | Elasticsearch |
| | | | | | | | |
+---------+-----------+---------+---------+-----------+---------+----------+-----------------+
| |
| Docker Engine |
| |
+--------------------------------------------------------------------------------------------+
| |
| Host OS |
| |
+--------------------------------------------------------------------------------------------+
Docker Engine 19.03.0 or newer.
You can create .env
file located in root folder and override default values.
PHP_CONTAINER_NAME=php # PHP-FPM container name
NGINX_CONTAINER_NAME=nginx # NGINX container name
DATABASE_CONTAINER_NAME=database # Database container name
S3_CONTAINER_NAME=minio # MinIO container name
STORAGE_LOGIN=storage_login # MinIO key/login
STORAGE_PASSWORD=storage_password # MinIO secret/password
MAILHOG_CONTAINER_NAME=mailhog # MailHog container name
DOCKER_HOST_UID=1000 # Your system user ID (UID)
DOCKER_HOST_GID=1000 # Your system group ID (GID)
RABBIT_MQ_CONTAINER_NAME=rabbit_mq # RabbitMQ container name
ELASTICSEARCH_CONTAINER_NAME=elasticsearch # Elasticsearch container name
Check your user ID:
$ id -u
# or
$ id -u <username>
Check your group ID:
$ id -g
# or
$ id -g <username>
8000
, http://127.0.0.1:8000
3306
inside docker network, and on port 13306
outside docker network.9000
, console is acccesible on http://127.0.0.1:9090
8025
, http://127.0.0.1:8025
. SMTP works on port 1025
, smtp://[mailhog_container_name]:1025
6379
inside docker network, and on port 16379
outside docker network.5672
, and RabbitMQ GUI work on port 15672
with guest
login and password.9200
and requires default credentials, login: elastic
and password: password
.9001
, idkey is PHPSTORM
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
database docker-entrypoint.sh --def ... Up 0.0.0.0:13306->3306/tcp,:::13306->3306/tcp, 33060/tcp
elasticsearch /bin/tini -- /usr/local/bi ... Up 0.0.0.0:9200->9200/tcp,:::9200->9200/tcp, 9300/tcp
mailhog MailHog Up 0.0.0.0:1025->1025/tcp,:::1025->1025/tcp, 0.0.0.0:8025->8025/tcp,:::8025->8025/tcp
minio /usr/bin/docker-entrypoint ... Up 0.0.0.0:9000->9000/tcp,:::9000->9000/tcp, 0.0.0.0:9090->9090/tcp,:::9090->9090/tcp
nginx /docker-entrypoint.sh ngin ... Up 0.0.0.0:1443->443/tcp,:::1443->443/tcp, 0.0.0.0:8000->80/tcp,:::8000->80/tcp
php docker-php-entrypoint php-fpm Up 9000/tcp
rabbit_mq docker-entrypoint.sh rabbi ... Up 15671/tcp, 0.0.0.0:15672->15672/tcp,:::15672->15672/tcp, 15691/tcp, 15692/tcp, 25672/tcp, 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp,:::5672->5672/tcp
redis docker-entrypoint.sh redis ... Up 0.0.0.0:16379->6379/tcp,:::16379->6379/tcp
To install Symfony Docker
, clone this repository, then build containers:
$ make build
and run:
$ make up
When containers are up and running create bucket and add policy using MinIO web interface: http://127.0.0.1:9090
. To log in use STORAGE_LOGIN
and STORAGE_PASSWORD
values.
Put your Symfony project into /app
folder.
To set up database connection in Symfony just add in .env
file:
DATABASE_URL=mysql://dbuser:password@database:3306/symfony?serverVersion=8.0
If you want to connect to MySQL from outside e.g. in PHPSTROM or any other SQL Client use credentials:
MYSQL_DATABASE: symfony
MYSQL_USER: dbuser
MYSQL_PASSWORD: password
MYSQL_HOST: ${DATABASE_CONTAINER_NAME:-database}
MYSQL_PORT: 13306
Type make help
to check Makefile commands.
To start docker containers in the background:
$ make up
Stop docker containers and remove docker network run:
$ make down
Usually you don't need to do anything inside container except in the php one. To get into any container run:
$ make sh