Docker: Development Mode vs Production Mode
Visual Overview
Comparison Table
| Feature | Development Mode | Production Mode |
|---|
| Docker File | Dockerfile.dev | Dockerfile |
| Docker Compose | docker-compose.dev.yml | docker-compose.build.yml |
| Environment Variables | .env.dev.docker | .env.docker |
| Container Name | webapp-dev | webapp |
| Image Name | ever-teams-webapp:dev | ever-teams-webapp:latest |
| Hot Reload | ✅ Yes | ❌ No |
| Image Size | ~1 GB | ~200 MB |
| Next.js Build | ❌ No (dev server) | ✅ Yes (optimized) |
| Mounted Volumes | ✅ Yes (source code) | ❌ No |
| DevDependencies | ✅ Installed | ❌ Removed |
| Multi-stage Build | ❌ No (1 stage) | ✅ Yes (2 stages) |
| Start Command | yarn dev:web | node server.js |
| Port | 3030 | 3030 |
| Rebuild Required | ❌ No | ✅ Yes (on each change) |
| Usage | Local Development | Deployment / Production |
Development Mode - How It Works
Architecture
Workflow
- You edit a file in
apps/web/src/components/MyComponent.tsx
- Docker volume syncs the change to the container
- Next.js detects the change (thanks to
CHOKIDAR_USEPOLLING=true)
- Next.js recompiles only the modified module
- Browser refreshes automatically (Hot Module Replacement)
- You see the result in a few seconds!
Advantages
- No rebuild: No need to rebuild the Docker image
- Fast feedback: See changes in seconds
- Isolated environment: Same environment as production
- No pollution: No need to install Node.js on your computer
Disadvantages
- ⚠️ Larger image: ~1 GB (contains all dev tools)
- ⚠️ Performance: Slightly slower than native dev server
- ⚠️ Polling: Uses more CPU to detect changes
Production Mode - How It Works
Architecture
Workflow