This is my basic workflow for using Docker and Docker Compose with Laravel development.
- Laravel 10
- React (Typescript)
- Docker
- MySql
- API authentication with Sanctum (WIP)
- Jetstream or React or Angular Frontend scaffold (WIP)
- SCSS or tailwind css styling (WIP)
- Permissions
- Role
- Database backup schedule midnight (WIP)
- CI/CD with circleCI
- Unit/Feature Testing
- Redis ready for caching and queuing
Make sure you have Docker for windows installed or Docker for mac installed on your system, and then copy this directory to a desired location on your development machine.
Navigate in your terminal to the project directory, and spin up the containers for the full web server stack by running docker-compose up -d --build
.
Install laravel dependencies
docker-compose run --rm composer install
Install node dependencies
docker-compose run --rm npm install
Generate laravel key
docker-compose run --rm artisan key:generate
Migrate database
docker-compose run --rm artisan migrate
Database seeding
docker-compose run --rm artisan db:seed
Queue work
docker-compose run --rm artisan queue:work --tries=3
Scheduler
docker-compose run --rm scheduler
PHPunit testing
docker-compose run --rm phpunit
- https://localhost
- https://localhost/api/documentation -> API Documentation
Available ports to the host machine:
- nginx -
:80
- mysql -
:3306
- php -
:9000
- redis -
:6379
During the PHP service setup portions of this course, there are portions that reference permission issues and utilizing some commands in the docker/php/Dockerfile
to work around them. That solution might not work for every system, and if your machine throws an error after implementing them, please see the updated docker/php/Dockerfile
and docker/php/www.conf
..
Using these updates, rebuilding your Docker network with docker-compose up -d --build
should resolve any permissions issues during site loads, composer installations, or artisan commands.
Renew certbot
docker-compose -f docker-compose.prod.yml run certbot renew
If you have any questions, please feel free to message me on LinkedIn or send me an email directly at tadena.anjo@gmail.com.