version: "3.9" services: db: image: mysql:8.0 container_name: lottery-mysql restart: always environment: MYSQL_DATABASE: lottery_db MYSQL_USER: lottery_user MYSQL_PASSWORD: ${MYSQL_PASSWORD} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} volumes: - lottery_mysql_data:/var/lib/mysql healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"] interval: 10s timeout: 5s retries: 5 networks: - lottery-network app: build: context: . dockerfile: Dockerfile.inferno container_name: lottery-backend restart: always depends_on: db: condition: service_healthy environment: - SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/lottery_db - SPRING_DATASOURCE_USERNAME=lottery_user - SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD} - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} - FRONTEND_URL=${FRONTEND_URL} # Logging configuration (external logback-spring.xml) - LOGGING_CONFIG=/app/config/logback-spring.xml - LOG_DIR=/app/logs volumes: # Mount secret file from tmpfs - /run/secrets:/run/secrets:ro # Mount logback config directory (editable on VPS without rebuilding) # Note: File must exist on host before mounting. Run setup-logging.sh first. - /opt/app/backend/config:/app/config:rw # Mount logs directory (persistent storage) - /opt/app/logs:/app/logs networks: - lottery-network # Don't expose port directly - nginx will handle it nginx: image: nginx:alpine container_name: lottery-nginx restart: always ports: - "80:80" - "443:443" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/conf.d:/etc/nginx/conf.d:ro # SSL certificates (if using HTTPS) # - ./nginx/ssl:/etc/nginx/ssl:ro depends_on: - app networks: - lottery-network volumes: lottery_mysql_data: networks: lottery-network: driver: bridge