services:
  badminton-scoreboard:
    container_name: badminton-scoreboard
    build:
      context: .
      dockerfile: Dockerfile
    image: badminton-scoreboard:latest
    restart: unless-stopped
    expose:
      - "8788"
    environment:
      PORT: 8788
      DB_HOST: ${DB_HOST:-192.168.0.15}
      DB_PORT: ${DB_PORT:-3307}
      DB_USER: ${DB_USER:-jianmiau}
      DB_PASSWORD: ${DB_PASSWORD}
      DB_DATABASE: ${DB_DATABASE:-badminton}
      DB_TABLE: ${DB_TABLE:-badminton}
      DB_HISTORY_TABLE: ${DB_HISTORY_TABLE:-history}

  badminton-scoreboard-web:
    container_name: badminton-scoreboard-web
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
    image: badminton-scoreboard-web:latest
    restart: unless-stopped
    depends_on:
      - badminton-scoreboard
    ports:
      - "3501:3501"
    environment:
      NGINX_PORT: 3501
      NGINX_SERVER_NAME: ${NGINX_SERVER_NAME:-_}
      SSL_CERT_DIR: /etc/nginx/certs
      SSL_CERT_FILE_NAME: ${SSL_CERT_FILE_NAME:-RSA-cert.pem}
      SSL_CHAIN_FILE_NAME: ${SSL_CHAIN_FILE_NAME:-RSA-chain.pem}
      SSL_KEY_FILE_NAME: ${SSL_KEY_FILE_NAME:-RSA-privkey.pem}
      UPSTREAM_HOST: badminton-scoreboard
      UPSTREAM_PORT: 8788
    volumes:
      - /volume1/homes/JianMiau/www/certificate:/etc/nginx/certs:ro
