/symfony6docker

Curso de udemy de symfony 6.2 ( actual version)

Primary LanguagePHPGNU General Public License v3.0GPL-3.0

🐳 Docker + PHP 8.2 + MySQL + Nginx + Symfony 6.2

Description

This is a complete stack for running Symfony 6.2 into Docker containers using docker-compose tool.

It is composed by 4 containers:

  • nginx, acting as the webserver.
  • php, the PHP-FPM container with the 8.2 version of PHP.
  • db which is the MySQL database container with a MySQL 8.0 image.

Installation

1.He tenido que entrar en el contenedor php -> ""docker exec -it symfony_dockerized-php-1 bash""

  1. he tenido que ir a la carpeta del proyecto -> "" cd /var/www/symfony ""

  2. y he tenido que installar el composer -> "" composer install ""

  3. He copiado y pegado el .env.nginx con el nombre "" .env.nginx.local ""

  4. Una vez dentro de ese archivo he puesto lo siguiente -> "" NGINX_BACKEND_DOMAIN='server_name' ""

No deberia haber problema de crear e iniciar docker.

FIN!

  1. 😀 Clone this repo.

  2. If you are working with Docker Desktop for Mac, ensure you have enabled VirtioFS for your sharing implementation. VirtioFS brings improved I/O performance for operations on bind mounts. Enabling VirtioFS will automatically enable Virtualization framework.

  3. Create the file ./.docker/.env.nginx.local using ./.docker/.env.nginx as template. The value of the variable NGINX_BACKEND_DOMAIN is the server_name used in NGINX.

  4. Go inside folder ./docker and run docker compose up -d to start containers.

  5. You should work inside the php container. This project is configured to work with Remote Container extension for Visual Studio Code, so you could run Reopen in container command after open the project.

  6. Inside the php container, run composer install to install dependencies from /var/www/symfony folder.

  7. Use the following value for the DATABASE_URL environment variable:

DATABASE_URL=mysql://app_user:helloworld@db:3306/app_db?serverVersion=8.0.33

You could change the name, user and password of the database in the env file at the root of the project.

To learn more

I have recorded a Youtube session explaining the different parts of this project. You could see it here:

Boilerplate para Symfony basado en Docker, NGINX y PHP8