Terrific Laravel #
A robust Laravel application setup with Docker, featuring multiple services for development and production environments.
Services Overview #
This application uses Docker Compose to orchestrate several services that work together to run the Laravel application securely and efficiently.
Core Services #
Laravel Application (app) #
- Image:
php:8.2-fpm - Purpose: Runs the PHP code for the Laravel application
- Configuration:
- Working directory:
/var/www/html - Connected to MySQL database and Valkey (Redis) for caching and queues
- Working directory:
Nginx Web Server (nginx) #
- Image:
nginx:latest - Purpose: Serves the Laravel application, handling HTTP requests
- Configuration:
- Custom configuration at
./nginx/default.conf - Integrated with Traefik for routing
- Protected by Coraza WAF
- Custom configuration at
MySQL Database (mysql) #
- Image:
mysql:8 - Purpose: Persistent data storage for the application
- Configuration:
- Database name:
laravel - Persistent volume:
mysql_data
- Database name:
Valkey (valkey) #
- Image:
eqalpha/valkey:latest - Purpose: Redis-compatible key-value store used for caching and queue management
- Used by: Laravel's cache and queue systems
Security & Routing #
Traefik (traefik) #
- Image:
traefik:v3.0 - Purpose: Reverse proxy and load balancer that manages routing and SSL certificates
- Features:
- Automatic SSL certificate generation via Let's Encrypt
- API dashboard (insecure mode enabled)
- Docker provider integration
- HTTP to HTTPS redirection
Coraza WAF (coraza) #
- Image:
owasp/coraza-proxy:latest - Purpose: Web Application Firewall based on OWASP ModSecurity
- Configuration:
- Protects the nginx service
- Integrated with Traefik
Development & Monitoring Tools #
Telescope with Auth (telescope_auth) #
- Image:
nginx - Purpose: Authentication layer for Laravel Telescope (debugging and monitoring tool)
- Configuration:
- Custom nginx configuration at
./nginx/telescope_auth.conf - Basic authentication protection
- Available at
telescope.yourdomain.com
- Custom nginx configuration at
Adminer (adminer) #
- Image:
adminer - Purpose: Database management tool for MySQL
- Configuration:
- Available at
db.yourdomain.com - Protected with basic authentication
- Available at
Nginx Configuration #
The Nginx service is configured using the file at ./nginx/default.conf which:
- Forwards PHP requests to the PHP-FPM service (app)
- Serves static files directly
- Configured for optimal Laravel deployment
- Works with Traefik for SSL termination
The telescope_auth.conf provides an authentication layer for the Laravel Telescope debugging tool, ensuring it's not accessible to unauthorized users.
Network Architecture #
All services are connected through the laravel_network bridge network, allowing them to communicate with each other securely while isolating them from other Docker containers on the host.
Volumes #
- mysql_data: Persistent storage for the MySQL database
- letsencrypt: Storage for SSL certificates generated by Let's Encrypt
Getting Started #
- Clone this repository
- Configure your domain names in the docker-compose.yml file (replace
yourdomain.cominstances) - Update email for Let's Encrypt in Traefik configuration
- Create the necessary nginx configuration files
- Run
docker-compose up -d
Security Notes #
- Basic authentication is configured for Telescope and Adminer
- Coraza WAF protects the application from common web vulnerabilities
- Traefik manages SSL certificates and HTTPS redirection
Custom Configuration #
You may need to create or customize:
./nginx/default.conf- Main nginx configuration./nginx/telescope_auth.conf- Authentication for Telescope- Update environment variables in docker-compose.yml for your specific setup
Local Development Hosts #
The following domains are already configured in /etc/hosts:
yourdomain.com- Main applicationtelescope.yourdomain.com- Laravel Telescope dashboarddb.yourdomain.com- Adminer database management interface