Docker Deployment Guide
A comprehensive guide to deploying the Bowlerplate stack using Docker and Docker Compose.
Docker Deployment Guide
This guide covers the deployment of the Bowlerplate ecosystem using Docker. The architecture is designed to be modular, sharing common infrastructure (Database, Redis, Proxy) across multiple applications.
🏗️ Architecture Overview
The system is composed of three main layers:
- Shared Proxy: A Caddy-based reverse proxy that handles incoming traffic and SSL.
- Shared Infrastructure: A single MariaDB and Redis instance serving all apps.
- Application Layer: Your Laravel backend, queue workers, scheduler, and documentation site.
🛠️ Prerequisites
- Docker and Docker Compose installed.
- Git (for cloning and version control).
- Basic knowledge of terminal commands.
🚀 Step-by-Step Setup
1. Initialize Shared Networks
Before starting any services, create the external networks that allow containers to communicate across different Compose projects.
docker network create web
docker network create shared2. Start Shared Infrastructure
Navigate to the infra directory and start the database and cache services.
cd infra
docker compose up -dThis starts:
- MariaDB (Host:
mysql, Port:3306) - Redis (Host:
redis, Port:6379)
3. Setup Reverse Proxy
The proxy handles routing for your domains (e.g., api.yourdomain.com).
cd ../proxy
docker compose up -dFor local development, use the Caddyfile provided which supports *.localhost domains. For production, update the Caddyfile with your real domains and remove auto_https off.
4. Provision Your Application
Run the provisioning script to create a dedicated database and user for your app.
cd ../infra
chmod +x provision-app.sh
./provision-app.sh bowlerplateSave the output! It will provide you with the DB_DATABASE, DB_USERNAME, and DB_PASSWORD for your .env file.
5. Configure the Application
Copy the production environment template and update it with the credentials from the previous step.
cd ../backend/laravel
cp .env.example .env.productionEdit .env.production:
DB_HOST=mysqlDB_DATABASE=bowlerplateDB_USERNAME=bowlerplate_userDB_PASSWORD=your_provisioned_passwordREDIS_HOST=redisAPP_URL=https://api.yourdomain.com
6. Build and Deploy
Build Documentation Site
The documentation site uses a "pre-built" Docker strategy. You must build it locally first.
cd ../../docs
bun install
bun run buildLaunch the Stack
Now, go back to the Laravel directory and start the application services. Note: This single compose file manages both the Backend and the Documentation site.
cd ../backend/laravel
docker compose up -d --buildThis will launch:
backend: The API server running on FrankenPHP (Port 8000).docs: The documentation site running on Bun (Port 3000).queue: The Laravel queue worker.scheduler: The Laravel task scheduler.
🔧 Useful Commands
Viewing Logs
# All services
docker compose logs -f
# Specific service
docker compose logs -f backendRunning Artisan Commands
docker compose exec backend php artisan migrate
docker compose exec backend php artisan tinkerRestarting Services
docker compose restart backend⚠️ Important Notes
- Volumes: Application data and logs are stored in named volumes (e.g.,
app_storage). Do not delete these volumes unless you want to wipe application state. - Permissions: The Dockerfile automatically sets permissions for
storageandbootstrap/cache. If you encounter permission issues, ensure your host directory is writable bywww-data(UID 33). - FrankenPHP: The backend uses FrankenPHP with Octane for high performance. It handles the web server and PHP execution in a single process.