3.3 KiB
3.3 KiB
Tournament Application Docker Setup
This directory contains the Docker configuration for the Tournament Application.
Files
Dockerfile- Multi-stage build for the applicationdocker-compose.yml- Complete stack with PostgreSQL and Nginxnginx.conf- Nginx reverse proxy configuration.dockerignore- Excludes unnecessary files from build context
Quick Start
Prerequisites
- Docker
- Docker Compose
Running the Application
-
Start the complete stack:
cd docker docker-compose up -d -
Access the application:
- Frontend: http://localhost:80
- API: http://localhost:4000
- Database: localhost:5432
-
View logs:
docker-compose logs -f -
Stop the application:
docker-compose down
Services
Tournament App (Port 4000)
- Node.js backend with Express
- React frontend (built and served by backend)
- Prisma ORM for database operations
- Socket.IO for real-time updates
PostgreSQL (Port 5432)
- Database:
tournament - User:
tournament_user - Password:
tournament_password
Nginx (Port 80/443)
- Reverse proxy for the application
- Static file serving
- SSL termination (configured but disabled by default)
Environment Variables
The application uses the following environment variables:
DATABASE_URL=postgresql://tournament_user:tournament_password@postgres:5432/tournament
PORT=4000
JWT_SECRET=your-super-secret-jwt-key-change-in-production
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
ADMIN_EMAIL=admin@tournament.com
Development
Building the Image
cd docker
docker build -t tournament-app -f Dockerfile ..
Running with Custom Environment
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
Production Deployment
Security Considerations
-
Change default passwords:
- Update
ADMIN_PASSWORDin docker-compose.yml - Update
JWT_SECRETto a strong random string - Update PostgreSQL password
- Update
-
Enable HTTPS:
- Uncomment HTTPS section in nginx.conf
- Add SSL certificates to
./ssl/directory - Update domain name in nginx.conf
-
Database Security:
- Use external PostgreSQL instance in production
- Implement proper backup strategy
- Use connection pooling
Scaling
The application can be scaled horizontally:
docker-compose up -d --scale tournament-app=3
Troubleshooting
Database Connection Issues
-
Check if PostgreSQL is running:
docker-compose ps postgres -
Check database logs:
docker-compose logs postgres
Application Issues
-
Check application logs:
docker-compose logs tournament-app -
Access application shell:
docker-compose exec tournament-app sh
Nginx Issues
-
Check nginx logs:
docker-compose logs nginx -
Test nginx configuration:
docker-compose exec nginx nginx -t
Data Persistence
The PostgreSQL data is persisted in a Docker volume named postgres_data. To backup:
docker-compose exec postgres pg_dump -U tournament_user tournament > backup.sql
To restore:
docker-compose exec -T postgres psql -U tournament_user tournament < backup.sql