This repository contains a Docker Compose configuration to run a Laravel application with PostgreSQL, Redis, Apache, Scheduler, and Queue.
- Docker
- Docker Compose
- An existing Laravel project
This repository offers different versions of the Docker Compose configuration for various web servers:
- http: Apache server serving the Laravel application over HTTP only.
- http and https: Apache server serving the Laravel application over both HTTP and HTTPS.
- force https: Apache server serving the Laravel application over HTTPS only and redirecting HTTP requests to HTTPS.
For installation instructions for each version, see the corresponding links above.
- web: Apache server serving the Laravel application and migrating the database on each start.
- db: PostgreSQL database.
- redis: Redis server for caching and queues.
- scheduler: Container for scheduled Laravel tasks.
- queue: Container for Laravel queue processing.
If you do not use the Scheduler and Queue in Laravel, you can remove these services from the docker-compose.yml
file:
-
Open the
docker-compose.yml
file. -
Remove the following sections:
scheduler: # ...existing code... queue: # ...existing code...
The following environment variables can be set in the .env
file:
MIGRATE
: Controls the database migration behavior. Possible values are:true
: Run migrations on each start.false
: Skip migrations.once
: Run migrations only if they haven't been run before (default).datetime
: Run migrations if the current time is before the specifiedMIGRATE_DATETIME
.
To set the MIGRATE
variable to datetime
and specify a MIGRATE_DATETIME
:
MIGRATE=datetime
MIGRATE_DATETIME=2025-12-31T14:48:59
-
To run a command in the
web
container:docker-compose exec web <command>
-
Example: Running Artisan commands:
docker-compose exec web php artisan <command>
This project is licensed under the MIT License. For more information, see the LICENSE file.