137 lines
3.2 KiB
Markdown
137 lines
3.2 KiB
Markdown
# Environment Configuration Guide
|
|
|
|
## Development Environment
|
|
|
|
For development, use the default `docker-compose.yml`:
|
|
|
|
```bash
|
|
cd docker
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Default Credentials (Development)
|
|
- **Admin Username**: `admin`
|
|
- **Admin Password**: `admin123`
|
|
- **Database**: `tournament`
|
|
- **Database User**: `tournament_user`
|
|
- **Database Password**: `tournament_password`
|
|
|
|
## Production Environment
|
|
|
|
For production deployment, use `docker-compose.prod.yml`:
|
|
|
|
```bash
|
|
cd docker
|
|
./deploy.sh
|
|
```
|
|
|
|
### Environment Variables (Production)
|
|
|
|
Create a `.env` file in the docker directory with the following variables:
|
|
|
|
```env
|
|
# Database Configuration
|
|
POSTGRES_PASSWORD=your_secure_postgres_password_here
|
|
|
|
# Application Configuration
|
|
JWT_SECRET=your_super_secure_jwt_secret_here_make_it_long_and_random
|
|
ADMIN_USERNAME=admin
|
|
ADMIN_PASSWORD=your_secure_admin_password_here
|
|
ADMIN_EMAIL=admin@yourdomain.com
|
|
|
|
# Optional: Custom domain for SSL
|
|
DOMAIN=yourdomain.com
|
|
```
|
|
|
|
### Security Checklist for Production
|
|
|
|
- [ ] Change `POSTGRES_PASSWORD` to a strong password
|
|
- [ ] Change `JWT_SECRET` to a long, random string
|
|
- [ ] Change `ADMIN_PASSWORD` to a secure password
|
|
- [ ] Update `ADMIN_EMAIL` to a valid email address
|
|
- [ ] Configure SSL certificates (optional)
|
|
- [ ] Set up proper firewall rules
|
|
- [ ] Configure backup strategy
|
|
- [ ] Set up monitoring and logging
|
|
|
|
### SSL Configuration
|
|
|
|
To enable HTTPS:
|
|
|
|
1. Create an `ssl` directory in the docker folder
|
|
2. Add your SSL certificates:
|
|
- `ssl/cert.pem` - SSL certificate
|
|
- `ssl/key.pem` - Private key
|
|
3. Uncomment the HTTPS section in `nginx.conf`
|
|
4. Update the domain name in `nginx.conf`
|
|
|
|
### Backup and Restore
|
|
|
|
#### Database Backup
|
|
```bash
|
|
docker-compose exec postgres pg_dump -U tournament_user tournament > backup.sql
|
|
```
|
|
|
|
#### Database Restore
|
|
```bash
|
|
docker-compose exec -T postgres psql -U tournament_user tournament < backup.sql
|
|
```
|
|
|
|
#### Full Application Backup
|
|
```bash
|
|
# Backup volumes
|
|
docker run --rm -v tournament_postgres_data:/data -v $(pwd):/backup alpine tar czf /backup/postgres_backup.tar.gz -C /data .
|
|
```
|
|
|
|
### Monitoring
|
|
|
|
#### Health Checks
|
|
- Application: `http://localhost/health`
|
|
- Database: Built into docker-compose
|
|
- Nginx: Built into docker-compose
|
|
|
|
#### Logs
|
|
```bash
|
|
# View all logs
|
|
docker-compose logs -f
|
|
|
|
# View specific service logs
|
|
docker-compose logs -f tournament-app
|
|
docker-compose logs -f postgres
|
|
docker-compose logs -f nginx
|
|
```
|
|
|
|
### Scaling
|
|
|
|
The application can be scaled horizontally:
|
|
|
|
```bash
|
|
docker-compose up -d --scale tournament-app=3
|
|
```
|
|
|
|
Note: You'll need to configure a load balancer (like nginx) to distribute traffic across multiple instances.
|
|
|
|
### Troubleshooting
|
|
|
|
#### Common Issues
|
|
|
|
1. **Port conflicts**: Change ports in docker-compose.yml
|
|
2. **Database connection issues**: Check if PostgreSQL is running and healthy
|
|
3. **Build failures**: Ensure all dependencies are properly installed
|
|
4. **Permission issues**: Check file permissions and ownership
|
|
|
|
#### Debug Commands
|
|
|
|
```bash
|
|
# Check container status
|
|
docker-compose ps
|
|
|
|
# Access application shell
|
|
docker-compose exec tournament-app sh
|
|
|
|
# Check database connection
|
|
docker-compose exec postgres psql -U tournament_user -d tournament
|
|
|
|
# View nginx configuration
|
|
docker-compose exec nginx nginx -t
|
|
``` |