generateDockerReadme static method
Implementation
static String generateDockerReadme(String projectName) {
return '''
# Docker Setup for $projectName
This project includes Docker configuration for easy deployment and development.
## 🚀 Quick Start
### Prerequisites
- Docker (v20.10+)
- Docker Compose (v2.0+)
### Production Deployment
1. **Build the Docker image:**
\`\`\`bash
make build
# OR
docker-compose build
\`\`\`
2. **Run the application:**
\`\`\`bash
make run
# OR
docker-compose up -d
\`\`\`
3. **Access the app:**
- Web App: http://localhost
- pgAdmin (if enabled): http://localhost:5050
### Development Mode
For hot-reload during development:
\`\`\`bash
make dev
# OR
docker-compose --profile dev up dev
\`\`\`
Access at: http://localhost:8080
## 📋 Available Commands
| Command | Description |
|---------|-------------|
| \`make build\` | Build Docker image |
| \`make run\` | Start production containers |
| \`make dev\` | Start development server with hot-reload |
| \`make stop\` | Stop all containers |
| \`make clean\` | Remove containers and volumes |
| \`make logs\` | View container logs |
| \`make restart\` | Restart all containers |
| \`make shell\` | Open shell in web container |
| \`make db-shell\` | Open PostgreSQL shell |
## 🏗️ Architecture
### Production Stack
- **Web**: Flutter web app served by Nginx
- **PostgreSQL**: Database (optional)
- **Redis**: Caching layer (optional)
- **pgAdmin**: Database management UI (optional)
### File Structure
\`\`\`
.
├── Dockerfile # Multi-stage build for Flutter web
├── docker-compose.yml # Production services
├── nginx.conf # Nginx configuration
├── .dockerignore # Files to exclude from Docker build
├── Makefile # Convenience commands
└── DOCKER.md # This file
\`\`\`
## 🔧 Configuration
### Environment Variables
Create a \`.env\` file in the project root:
\`\`\`env
# Database
POSTGRES_DB=${projectName}_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_password
# Redis
REDIS_PASSWORD=your_redis_password
# App
NODE_ENV=production
\`\`\`
### Ports
Default port mappings:
- Web App: 80
- PostgreSQL: 5432
- Redis: 6379
- pgAdmin: 5050 (dev profile)
- Dev Server: 8080 (dev profile)
To change ports, edit \`docker-compose.yml\`.
## 🛠️ Troubleshooting
### Container won't start
\`\`\`bash
# Check logs
make logs
# Restart containers
make restart
\`\`\`
### Clean rebuild
\`\`\`bash
# Remove everything and rebuild
make clean
make build
make run
\`\`\`
### Database connection issues
\`\`\`bash
# Check if PostgreSQL is running
docker ps
# Access database shell
make db-shell
\`\`\`
### Permission issues
\`\`\`bash
# Fix volume permissions
sudo chown -R \$USER:\$USER .
\`\`\`
## 📦 Building for Different Platforms
### Web Only (Current Setup)
Already configured! Just use \`make build\`.
### Android/iOS
For mobile deployments, use Flutter's native build tools:
\`\`\`bash
flutter build apk --release # Android
flutter build ios --release # iOS
flutter build appbundle --release # Android App Bundle
\`\`\`
## 🔐 Security Notes
1. **Change default passwords** in \`.env\` and \`docker-compose.yml\`
2. **Use secrets** for production (Docker Swarm or Kubernetes)
3. **Enable HTTPS** with Let's Encrypt or similar
4. **Restrict database access** to internal network only
5. **Regular updates** - keep base images updated
## 🚀 Deployment
### Deploy to Cloud
**Docker Hub:**
\`\`\`bash
docker tag ${projectName}_web your-username/${projectName}:latest
docker push your-username/${projectName}:latest
\`\`\`
**AWS ECS, Google Cloud Run, or Azure:**
Follow their respective documentation for container deployment.
## 📝 Notes
- The production build uses Nginx for optimal performance
- Static assets are cached for 1 year
- Gzip compression is enabled for better performance
- Development mode mounts the source code for hot-reload
- Database and Redis data persist in Docker volumes
## 🤝 Contributing
When adding new services, update:
1. \`docker-compose.yml\`
2. This README
3. Network configuration if needed
---
For more information, visit the [Flutter Docker documentation](https://flutter.dev/docs/deployment/web).
''';
}