Introduction
Macuin uses Docker to provide a consistent, isolated development environment across different machines. The application runs in a multi-container setup orchestrated by Docker Compose, ensuring all services work together seamlessly.Multi-Container Architecture
The Macuin platform is built on a microservices-inspired architecture with four main containers:Nginx
Web server and reverse proxy handling HTTP requests
Laravel App
PHP-FPM container running the Laravel application
PostgreSQL
Database service for persistent data storage
Node
Frontend asset compilation with Vite
Architecture Diagram
Service Dependencies
The containers have a specific startup order managed by Docker Compose:- PostgreSQL starts first with health checks
- Laravel App waits for PostgreSQL to be healthy
- Nginx starts after the Laravel app is ready
- Node runs independently for frontend assets
The dependency chain ensures the database is ready before Laravel attempts to connect, preventing connection errors during startup.
Networking
All services communicate through a dedicated Docker bridge network calledlaravel_network. This provides:
- Service Discovery: Containers can reach each other by service name (e.g.,
app,postgres) - Isolation: The network is isolated from other Docker containers
- DNS Resolution: Automatic DNS resolution for service names
Inter-Service Communication
- Nginx → Laravel App:
fastcgi_pass app:9000(PHP-FPM) - Laravel App → PostgreSQL:
DB_HOST=postgreson port5432 - Host → Nginx:
localhost:8000(mapped to container port 80) - Host → Vite:
localhost:5173(hot module replacement)
Benefits of Docker Setup
Consistency
Same environment across development, staging, and production
Isolation
Dependencies contained without affecting host system
Quick Setup
New developers can start with a single command
Version Control
Infrastructure as code in version control
Key Advantages
Development Speed- No manual installation of PHP, PostgreSQL, or Node
- Pre-configured services with optimal settings
- Hot reloading for both backend and frontend
- Health checks ensure services are ready before dependent services start
- Automatic restart on failure
- Consistent behavior across team members
- Easy to add new services (Redis, queue workers, etc.)
- Can scale individual services independently
- Simple to replicate for testing environments
Port Mappings
The following ports are exposed to the host machine:| Service | Container Port | Host Port | Purpose |
|---|---|---|---|
| Nginx | 80 | 8000 | Web application access |
| PostgreSQL | 5432 | 5432 | Database connections |
| Node (Vite) | 5173 | 5173 | Frontend dev server & HMR |
Data Persistence
Two named volumes ensure data persists across container restarts:- postgres_data: Stores PostgreSQL database files
- node_modules: Caches Node.js dependencies for faster builds
Next Steps
Configuration
Learn how to customize Docker settings
Services
Detailed documentation for each service