Template for using Laravel + MySQL in a Docker environment.
First of all, you need to make a copy of the file .env.example in the project root folder, and rename it as .env. This also need to be done with the .env.example file within the src folder.
Remember to set all appropriate environment variables, if needed.
For the first launch of the program, you must execute the following command. This creates all the containers necessary to run the application.
docker compose buildAfter that completes, run the following to install and compile the dependencies for the application:
docker compose run --rm composer install
docker compose run --rm npm install
docker compose run --rm npm run buildFinally, launch all application containers, and run the necessary migrations:
docker compose up
docker compose run --rm artisan migrateFor all subsequent launches, you just need to execute:
docker compose upWhen you are finished, you can close the application (and destroy all containers) by using:
docker compose downYou can access the application through http://localhost:8000/.