Dockavel Logo

Dockavel

Laravel Docker Production Stack

πŸš€ Laravel Docker Production Stack

Dockavel Logo

Production-ready Docker environment for Laravel 12+ with automated deployment, SSL management, and Cloudflare detection.

Laravel PHP Docker License GitHub stars GitHub release GitHub issues PRs Welcome


πŸ“‹ Table of Contents


🎯 Why This Stack?

This stack started as a personal setup that evolved over several years of Laravel deployments. It tries to address common pain points and provide sensible defaults out of the box.

What it offers:

  • Zero-config deployment β€” One command deploys dev or production
  • Security defaults β€” SSH hardening, Fail2Ban, UFW firewall, automated updates
  • SSL automation β€” Let's Encrypt with auto-renewal via Certbot
  • Smart Cloudflare detection β€” Automatically adapts to proxy/DNS-only mode
  • Production optimizations β€” OPcache, Redis caching, optimized PHP-FPM
  • Real-time features β€” Horizon for queues, supervisor for workers
  • Developer experience β€” Hot reload with Vite, interactive scripts

If it can save you some setup time, that's great. Feel free to adapt it to your needs.


✨ Features

πŸ”§ Core Stack

  • Laravel 12+ with PHP 8.4+
  • Nginx with optimized configuration & security headers
  • MySQL 8.0 with custom tuning
  • Redis 7 for cache/sessions/queues
  • Horizon for queue management
  • Supervisor for background workers
  • Certbot for SSL certificate management

πŸš€ Automation Scripts

  • deploy.sh β€” Interactive deployment (dev/prod)
  • server-setup.sh β€” One-time server initialization
  • update.sh β€” Update after git pull
  • backup.sh β€” Database backups
  • laravel-helper.sh β€” Quick Laravel commands
  • create-ssl-certs.sh β€” Dev SSL certificates

πŸ”’ Security

  • SSH hardening (key-only auth, root disabled)
  • Fail2Ban protection (automatic IP banning)
  • UFW firewall (ports 22, 80, 443)
  • Automated security updates
  • Nginx rate limiting & security headers
  • Sensitive file protection (.env, .git)

🌐 Production Ready

  • Cloudflare detection (proxy vs DNS-only)
  • Health checks on all services
  • Resource limits (CPU/memory)
  • Zero-downtime deployments
  • Comprehensive logging
  • Graceful shutdowns

⚑ Quick Start

1️⃣ First-Time Server Setup

Run this once on a fresh Ubuntu server (as root):

curl -fsSL https://raw.githubusercontent.com/mg2k4/Dockavel/main/scripts/server-setup.sh | sudo bash

This configures Docker, firewall, Fail2Ban, deploy user, and security hardening.

⏱️ Duration: ~5 minutes


2️⃣ Deploy Application

SSH into your server as the deploy user:

ssh deploy@your-server-ip
cd /var/www
git clone git@github.com:mg2k4/Dockavel.git app
cd app

Development:

./scripts/deploy.sh dev

Production:

./scripts/deploy.sh prod

The script handles everything: environment setup, Docker build, dependencies, SSL, migrations, and optimization.

⏱️ Duration: ~3-5 minutes (first deploy)


3️⃣ Access Your Application

Development:

http://localhost          (HTTP)
https://localhost         (HTTPS, self-signed)
http://localhost:5173     (Vite HMR)

Production:

https://your-domain.com   (with Let's Encrypt SSL)

πŸ—οΈ Architecture

Docker Services

Service Purpose Exposed Ports
app PHP-FPM + Laravel application -
webserver Nginx reverse proxy 80, 443
db MySQL 8.0 database 3306 (dev)
caching Redis for cache/session/queue 6379 (dev)
supervisor Horizon + background workers -
scheduler Laravel task scheduler (cron) -
certbot SSL certificate management -

See Docker Architecture for detailed service configurations.


πŸ“š Documentation

Core Documentation


πŸ“¦ Requirements

Server: Ubuntu 20.04+, 2GB RAM minimum Local: Docker Desktop, Git

See Installation Guide for full details.


🚦 Common Commands

Deployment

./scripts/deploy.sh dev              # Deploy development
./scripts/deploy.sh prod             # Deploy production
./scripts/update.sh                  # Update after git pull

Container Management

docker compose ps                    # List containers
docker compose logs -f               # Follow all logs
docker compose logs -f app           # Follow app logs
docker compose exec app bash         # Shell into app
docker compose restart               # Restart services
docker compose down                  # Stop services

Laravel Commands

./scripts/laravel-helper.sh          # Interactive menu
docker compose exec app php artisan migrate
docker compose exec app php artisan queue:work
docker compose exec app php artisan horizon

Database

./scripts/backup.sh                  # Backup database
docker compose exec db mysql -u root -p

πŸ”„ Updates

cd /var/www/app
git pull origin main
./scripts/update.sh

See Scripts Reference for more commands.


🀝 Contributing

All contributions are welcome! Whether it's fixing a typo, improving docs, or adding features β€” everything helps.

See Contributing Guidelines for details.


πŸ“ License

MIT License β€” Copyright (c) 2026 mg2k4

See LICENSE for full text.


πŸ™ Acknowledgments

  • Laravel β€” The PHP framework for web artisans
  • Docker β€” Containerization platform
  • Nginx β€” High-performance web server
  • Let's Encrypt β€” Free SSL certificates
  • Cloudflare β€” CDN and DDoS protection

πŸ’¬ Support


πŸ—ΊοΈ Roadmap

Some ideas for future versions, time permitting:

v1.1

  • Automated backup to S3/DigitalOcean Spaces
  • Monitoring with Prometheus/Grafana
  • GitHub Actions CI/CD templates

v2.0

  • Kubernetes deployment manifests
  • PostgreSQL support
  • Multi-region setup guide

PRs are welcome if you want to tackle any of these!


Shared hoping it might be useful to someone

⬆ Back to Top