You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like this application to have a Docker environment.
I should be able to run this application during development. So, during development, I will need to attach the code as volumne, vite should run with hot-reload. And, it should also give me a MySQL database with PHPMyAdmin interface.
On production, I should have the application running in prod mode. Should have MySQL as well.
Docker Setup for Development and Production
Quick Start
Development:
make dev # Starts everything (app, vite, mysql, adminer)
make migrate # Run migrations
make seed # Seed database
Production:
make build-prod # Build production image
make push # Push to Docker Hub
Architecture Overview
Development Environment:
docker-compose.yml (Development)
---------------------------------
• app (PHP 8.4 + Nginx) - port 80
- Source code mounted as volumes (hot-reload)
- Runs: php-fpm, nginx, queue worker
• vite (Node.js) - port 5173
- Runs: npm run dev
- HMR enabled for instant frontend updates
• mysql - port 3306
- Persistent data volume
• adminer - port 8080
- Lightweight database management UI (~90MB vs 500MB phpMyAdmin)
Production Environment:
docker-compose.prod.yml (Production)
-------------------------------------
• app (Optimized multi-stage build)
- Code baked into image
- Composer deps (--no-dev --optimize-autoloader)
- Frontend assets pre-built (npm run build)
- Ready to push to Docker Hub
• mysql (Production config)
- Persistent data volume
- Optimized settings
Docker Hub Ready: Tagged and pushable to your repository
Makefile Commands
Development:
make dev # Start development environment
make up # Start all containers
make down # Stop all containers
make restart # Restart all containers
make logs # View logs from all services
make logs-app # View app logs only
make logs-vite # View Vite logs only
make shell # Open shell in app container
make tinker # Open Laravel Tinker
make migrate # Run database migrations
make seed # Run database seeders
make fresh # Fresh database with seeds
make test# Run all tests
make test-filter # Run specific test (usage: make test-filter FILTER=testName)
make composer-install # Install composer dependencies
make npm-install # Install npm dependencies
make composer-require # Require composer package (usage: make composer-require PKG=vendor/package)
make npm-add # Add npm package (usage: make npm-add PKG=package-name)
make format # Format all code (PHP + TypeScript/React)
make pint # Format PHP code only
make lint # Lint and fix TypeScript/React code
Production:
make build-prod # Build production Docker image
make prod-up # Start production environment locally
make prod-down # Stop production environment
make prod-logs # View production logs
make push # Tag and push to Docker Hub (latest + version tag)
make push-latest # Push only latest tag
make push-version # Push only version tag (usage: make push-version VERSION=v1.0.0)
Utility:
make help# Show all available commands
make clean # Remove all containers, volumes, and images
make ps # Show running containers
make db-shell # Open MySQL shell
Environment Variables
Two separate .env files:
.env - Development configuration
.env.production - Production configuration (DB credentials, APP_ENV=production)
Benefits of This Approach
Development:
Instant code reflection (no rebuilds needed)
Full Laravel tooling available
Database UI for quick debugging
Vite HMR for fast frontend iteration
Production:
Single optimized image (~200-300MB)
No source code mounting (security)
Ready for any deployment (AWS, DigitalOcean, etc.)
Version controlled via Docker tags
General:
Consistent environments across team
Simple commands via Makefile (just make dev to start)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like this application to have a Docker environment.
I should be able to run this application during development. So, during development, I will need to attach the code as volumne, vite should run with hot-reload. And, it should also give me a MySQL database with PHPMyAdmin interface.
On production, I should have the application running in prod mode. Should have MySQL as well.
Docker Setup for Development and Production
Quick Start
Development:
Production:
Architecture Overview
Development Environment:
Production Environment:
File Structure
Key Features
Makefile Benefits:
make help)makeinstalledDevelopment:
Production:
Makefile Commands
Development:
Production:
Utility:
Environment Variables
Two separate .env files:
.env- Development configuration.env.production- Production configuration (DB credentials, APP_ENV=production)Benefits of This Approach
Development:
Production:
General:
make devto start)Beta Was this translation helpful? Give feedback.
All reactions