services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: travianz-web
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www/html
    environment:
      - APACHE_DOCUMENT_ROOT=/var/www/html
    depends_on:
      - db
    networks:
      - travianz-network
    restart: unless-stopped

  db:
    image: mariadb:latest
    container_name: travianz-db
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-${MYSQL_ROOT_PASSWORD:-rootpassword}}
      MARIADB_DATABASE: ${MARIADB_DATABASE:-${MYSQL_DATABASE:-travian}}
      MARIADB_USER: ${MARIADB_USER:-${MYSQL_USER:-travianz}}
      MARIADB_PASSWORD: ${MARIADB_PASSWORD:-${MYSQL_PASSWORD:-travianzpass}}
    volumes:
      - db-data:/var/lib/mysql
      - ./var/db:/docker-entrypoint-initdb.d:ro
    ports:
      - "3306:3306"
    networks:
      - travianz-network
    restart: unless-stopped
    command: --sql_mode=""

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: travianz-phpmyadmin
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: ${MARIADB_ROOT_PASSWORD:-${MYSQL_ROOT_PASSWORD:-rootpassword}}
    ports:
      - "8081:80"
    depends_on:
      - db
    networks:
      - travianz-network
    restart: unless-stopped

volumes:
  db-data:
    driver: local

networks:
  travianz-network:
    driver: bridge
