- Docker Installed.
- Docker Compose Installed.
Make sure that the ports:
- 8000 For Nginx.
- 6379 For Redis,
- 5050 For Adminer,
- 3306 For Mysql.
- 9000 For php7.4-fpm.
are available on your host, if you use Mysql, Redis and Apache2 on the default ports you need to stop them before running docker containers by the commands:
make stop
You can check all opened ports on you device by the command:
sudo netstat -anptu # Run sudo apt-get install net-tools to install netstat
Afetr that change the dirctory to the root of your project and run this command to start the containers:
make docker-build
make docker-up
- nginx-container as web server listen on port 8000
- node-container to work with Wepack Encore
- php7.4-container
- redis-container
- adminer-container listen on port 5050(http://localhost:5050) to see the database and the tables.
- mariadb-container as sql server
- messenger-container to run the worker
messenger:consume
- mercure-container on port 3000
- mail-container on http://localhost:8025 to test email in dev environment.
- blackfire-container
After you run the containers in the terminal, you need to configure the .env file:
DATABASE_URL=mysql://root:root@mariadb-service:3306/db_name?serverVersion=mariadb-10.4.11 # Replace only your the db_name.
REDIS_URL=redis://redis
MESSENGER_TRANSPORT_DSN=redis://redis:6379
Now you need to go the php7.4-container to create the database abd run the migrations, first to go inside the container run this:
sudo docker exec -it php7.4-container bash
So there you can run the php bin/console
, composer
or symfony
commands, so create the database as usual:
symfony console doctrine:database:create
symfony console doctrine:schema:update --force
To update the packeges of nodejs, you need first to go inside the container and update node modules:
sudo docker exec -it node-container sh
yarn install
# or
docker exec node-conatiner yarn install
Then go to adminer container at http://localhost:5050 to see the tables. The password is root and replace the db_name by your database name or remove it.
If evverything is good now you can see your application on http://localhost:8000.
If you want to see the logs of a conatiner in case you want to debug an error:
docker logs messenger-container -f #docker logs container_name -f
docker logs mercure-container -f