# Adds the Admincraft bridge to a Minecraft stack you already run.
#
# Layered on top of your own file rather than replacing it, so nothing about
# your server changes:
#
#   docker compose -f docker-compose.yml -f docker-compose.admincraft.yml up -d
#
# Only the new container starts; Minecraft keeps running.
#
# Set SECRET_KEY before the first run. Generate one with:
#   openssl rand -hex 32
#
# For Java, also set SERVER_TYPE to java and fill in the RCON values. The bridge
# defaults to Bedrock and refuses a Java profile without it.
services:
  websocket:
    container_name: websocket
    image: joanroig/admincraft-websocket:latest
    restart: always
    labels:
      # Enabled unless ADMINCRAFT_AUTO_UPDATE=false is set in .env.
      com.centurylinklabs.watchtower.enable: "${ADMINCRAFT_AUTO_UPDATE:-true}"
    ports:
      # Keep this closed to the internet: it can run commands on your server.
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      SECRET_KEY: YOUR_SECRET_KEY_HERE
      USE_SSL: "false"

      # bedrock or java
      SERVER_TYPE: bedrock

      # The name of your Minecraft container, if it is not "minecraft".
      MC_NAME: minecraft

      # Java only. RCON_HOST is the Minecraft service name on the Docker
      # network; the port must never be published to the host.
      # RCON_HOST: minecraft
      # RCON_PORT: "25575"
      # RCON_PASSWORD: YOUR_RCON_PASSWORD

  admincraft-updater:
    container_name: admincraft-updater
    image: nickfedor/watchtower:1.16.1
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    # Labels plus the explicit container name ensure this never updates
    # Minecraft, backups, databases, or any unrelated container on the host.
    command: --label-enable --cleanup --interval 86400 websocket
    environment:
      WATCHTOWER_NO_STARTUP_MESSAGE: "true"
