version: "3"
services:
  minecraft:
    container_name: minecraft
    image: itzg/minecraft-bedrock-server
    restart: always
    environment:
      # Enable SSH
      ENABLE_SSH: true
      # Timezone used for the server's log timestamps
      TZ: CET
      # Server settings
      EULA: "TRUE"
      GAMEMODE: survival
      SERVER_NAME: Moaicraft
      LEVEL_NAME: Moaiworld
      LEVEL_SEED: -2746961253358476370
      DIFFICULTY: normal
      ALLOW_CHEATS: true
      ALLOW_LIST: true
      CLIENT_SIDE_CHUNK_GENERATION_ENABLED: false # Beware: enabling this may cause stuttering/freezing
      MAX_THREADS: 0 # Maximum threads
      VIEW_DISTANCE: 20 # Memory-hungry: raise it (40+) only if the VM has headroom
      CONTENT_LOG_FILE_ENABLED: true

    # Expose the mc-server-runner's SSH port to just the backup container
    expose:
      - 2222
    ports:
      - 19132:19132/udp
    volumes:
      - ./minecraft:/data
    stdin_open: true
    tty: true

  backup:
    container_name: backup
    image: kaiede/minecraft-bedrock-backup
    restart: always
    depends_on:
      # Make sure the minecraft service starts before the backup
      minecraft:
        condition: service_healthy
    volumes:
      # Map your backups folder into /backups
      - ./backups:/backups
      # Map the data folders for the server
      - ./minecraft:/minecraft
      # (Optional) Map a configuration folder separately from the backups.
      - ./backups-config:/config

  websocket:
    container_name: websocket
    image: joanroig/admincraft-websocket:latest
    restart: always
    depends_on:
      # Make sure the minecraft service starts before the websockets service
      minecraft:
        condition: service_healthy
    ports:
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket
      # Only needed when USE_SSL is "true", see the self-signed SSL alternative
      # - ./certs:/usr/src/app/certs:ro
    environment:
      # Generate your own with: openssl rand -hex 32
      SECRET_KEY: YOUR_SECRET_KEY_HERE
      SERVER_TYPE: bedrock
      # The recommended setup reaches this port over Tailscale, which already
      # encrypts the traffic. Set to "true" only for the self-signed SSL
      # alternative, which exposes port 8080 to the internet.
      USE_SSL: "false"
