# ass Docker compose.yaml v0.2.0
# authors:
#  - tycrek <t@tycrek.com> (https://tycrek.com/)
#  - Zusier <zusier@pm.me> (https://github.com/Zusier)

services:
  #reiverr:
  #  image: ghcr.io/aleksilassila/reiverr:latest
  #  container_name: reiverr
  #  ports:
  #    - 9494:9494
  #  environment:
  #    - SECRET=petarisgaming # optional, used to sign JWT tokens for authentication. If not set, sessions will not persist between server restarts. Use a random string.
  #    - ADMIN_USERNAME=petar # optional
  #    - ADMIN_PASSWORD=petargaming # optional
  #  volumes:
  #    - ./docker/revierr/config:/config
  #    - ./docker/revierr/plugins:/plugins
  #  restart: unless-stopped

  veloren-server:
    image: registry.gitlab.com/veloren/veloren/server-cli:weekly
    stdin_open: true
    tty: true
    container_name: veloren-game-server-master
    ports:
      - "14004:14004"
      - "14005:14005"
      - "14006:14006/udp"
    restart: on-failure:0
    network_mode: "host"
    volumes:
        - "./docker/veloren/userdata:/opt/userdata"
    environment:
        - RUST_LOG=debug,common::net=info

  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: --interval 30 --stop-timeout 130s --cleanup veloren-game-server-master
    network_mode: "host"
    restart: on-failure:0

  broadcast-box:
    restart: "unless-stopped"
    environment:
        - INCLUDE_PUBLIC_IP_IN_NAT_1_TO_1_IP=yes
        - HTTP_ADDRESS=:8443
        - UDP_MUX_PORT=8444
        - UDP_MUX_PORT_WHIP=8445
    image: seaduboi/broadcast-box:latest
    hostname: broadcast-box
    container_name: broadcast-box
    network_mode: "host"
    privileged: true

  postgres:
    image: postgres:15.2-alpine
    container_name: postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: ztnet
    volumes:
      - "./docker/postgres/data:/var/lib/postgresql/data"
    networks:
      - app-network

  zerotier:
    image: zyclonite/zerotier:1.14.2
    hostname: zerotier
    container_name: zerotier
    restart: unless-stopped
    volumes:
      - "./docker/zerotier:/var/lib/zerotier-one"
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    networks:
      - app-network
    ports:
      - "9993:9993/udp"
    environment:
      - ZT_OVERRIDE_LOCAL_CONF=true
      - ZT_ALLOW_MANAGEMENT_FROM=172.31.255.0/29

  ztnet:
    image: sinamics/ztnet:latest
    container_name: ztnet
    working_dir: /app
    volumes:
      - "./docker/zerotier:/var/lib/zerotier-one"
    restart: unless-stopped
    ports:
      - 3000:3000
    # - 127.0.0.1:3000:3000  <--- Use / Uncomment this line to restrict access to localhost only
    environment:
      POSTGRES_HOST: postgres
      POSTGRES_PORT: 5432
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: ztnet
      NEXTAUTH_URL: "https://ip.petar.cc:3000" # !! Important !! Set the NEXTAUTH_URL environment variable to the canonical URL or IP of your site with port 3000
      NEXTAUTH_SECRET: "petar_gaming"
      NEXTAUTH_URL_INTERNAL: "http://ztnet:3000" # Internal NextAuth URL for 'ztnet' container on port 3000. Do not change unless modifying container name.
    networks:
      - app-network
    links:
      - postgres
    depends_on:
      - postgres
      - zerotier

  #gitlab-server:
  #  image: 'gitlab/gitlab-ee:latest'
  #  container_name: gitlab-server
  #  hostname: 'git.petar.cc'
  #  environment:
  #    GITLAB_OMNIBUS_CONFIG: |
  #      #external_url 'https://git.petar.cc'
  #      gitlab_rails['initial_root_password'] = '4CQ9s3ELoKsf%I'
  #  ports:
  #    - '8069:80'
  #    - '2022:22'
  #  volumes:
  #    - "./docker/gitlab/config:/etc/gitlab"
  #    - "./docker/gitlab/logs:/var/log/gitlab"
  #    - "./docker/gitlab/data:/var/opt/gitlab"
  #  shm_size: '256m'
  #  restart: always

  #gitlab-runner:
  #  image: 'gitlab/gitlab-runner:latest'
  #  container_name: gitlab-runner
  #  volumes:
  #    - /var/run/docker.sock:/var/run/docker.sock
  #    - "./docker/gitlab-runner/config:/etc/gitlab-runner"
  #  restart: always

  teamspeak:
    image: teamspeaksystems/teamspeak6-server:latest
    container_name: teamspeak-server
    restart: unless-stopped
    ports:
      - "9987:9987/udp"   # Voice Port
      - "30033:30033/tcp" # File Transfer
      - "10080:10080/tcp" # Web Query
    environment:
      - TSSERVER_LICENSE_ACCEPTED=accept
    volumes:
      - ./docker/teamspeak:/var/tsserver

networks:
  app-network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.31.255.0/29
