Files
OpenTournament/docker
2025-07-19 17:24:17 +02:00
..
2025-07-19 12:21:46 +02:00
2025-07-19 12:21:46 +02:00
2025-07-19 12:21:46 +02:00
2025-07-19 17:24:17 +02:00
2025-07-19 12:24:28 +02:00
2025-07-19 12:21:46 +02:00
2025-07-19 12:21:46 +02:00
2025-07-19 12:21:46 +02:00
2025-07-19 12:21:46 +02:00

Tournament Application Docker Setup

This directory contains the Docker configuration for the Tournament Application.

Files

  • Dockerfile - Multi-stage build for the application
  • docker-compose.yml - Complete stack with PostgreSQL and Nginx
  • nginx.conf - Nginx reverse proxy configuration
  • .dockerignore - Excludes unnecessary files from build context

Quick Start

Prerequisites

  • Docker
  • Docker Compose

Running the Application

  1. Start the complete stack:

    cd docker
    docker-compose up -d
    
  2. Access the application:

  3. View logs:

    docker-compose logs -f
    
  4. 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

  1. Change default passwords:

    • Update ADMIN_PASSWORD in docker-compose.yml
    • Update JWT_SECRET to a strong random string
    • Update PostgreSQL password
  2. Enable HTTPS:

    • Uncomment HTTPS section in nginx.conf
    • Add SSL certificates to ./ssl/ directory
    • Update domain name in nginx.conf
  3. 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

  1. Check if PostgreSQL is running:

    docker-compose ps postgres
    
  2. Check database logs:

    docker-compose logs postgres
    

Application Issues

  1. Check application logs:

    docker-compose logs tournament-app
    
  2. Access application shell:

    docker-compose exec tournament-app sh
    

Nginx Issues

  1. Check nginx logs:

    docker-compose logs nginx
    
  2. 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