# ---------------------------------------------------------------------------
#  UTP Connect — your park's web page, for Ultimate Theme Park
#
#  The installer writes this file and everything around it for you:
#
#      curl -fsSL https://ultimate-themepark.com/install.sh | bash
#
#  By hand: put this file in a folder of its own on your server, with a file
#  named .env next to it that holds your address and the build of UTP Connect
#  for your plugin (the installer finds it: https://ultimate-themepark.com/docs):
#
#      DOMAIN=connect.your-park.com
#      UTP_VERSION=5.0.0
#
#  then start it:
#
#      docker compose up -d
#
#  The address must point at this server, with ports 80 and 443 open: the HTTPS
#  certificate is obtained and renewed on its own.
#
#  Your music is uploaded from UTP Connect's administration (Media library), and
#  kept in the "music" folder next to this file. The folder must belong to the
#  user UTP Connect runs as:   chown -R 1001:1001 music
#
#  Updating: change UTP_VERSION in .env, then  docker compose up -d
#  Full guide: https://ultimate-themepark.com/docs
# ---------------------------------------------------------------------------

name: utp-connect

services:
  utp-connect:
    image: ghcr.io/stallstudio/utp-connect:${UTP_VERSION:?write UTP_VERSION=5.0.0 (the build of UTP Connect for your plugin) in the .env file next to docker-compose.yml}
    restart: unless-stopped
    environment:
      PUBLIC_URL: https://${DOMAIN:?write DOMAIN=connect.your-park.com in a .env file next to docker-compose.yml}
    volumes:
      # Settings, rides, regions, photos and the link secret. Back this up.
      - utp-data:/data
      # The music the administration uploads, in the folder next to this file: a web
      # server in front serves it under /music/ straight from there. Back it up too.
      - ./music:/data/music
      # Where UTP Connect asks the installer's updater for an update (utp-connect-update.path).
      # Without the installer, it stays empty and the updates are made by hand.
      - ./updater:/updater

  caddy:
    image: caddy:2-alpine
    restart: unless-stopped
    depends_on:
      - utp-connect
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    configs:
      - source: caddyfile
        target: /etc/caddy/Caddyfile
    volumes:
      - ./music:/srv/music:ro
      - caddy-data:/data
      - caddy-config:/config

configs:
  caddyfile:
    content: |
      ${DOMAIN} {
        handle_path /music/* {
          root * /srv/music
          file_server
        }
        reverse_proxy utp-connect:3000
      }

volumes:
  utp-data:
  caddy-data:
  caddy-config:
