---
version: "{{ skylab_compose_version }}"


networks:
  minecraft:
    name: minecraft
    driver: overlay
    ipam:
      driver: default
      config:
        - subnet: {{ app.networks.ext }}


volumes:
{% for key, value in app.volumes.items() %}
  minecraft-{{ key }}:
    name: datastore{{ value }}
    driver: glusterfs
{% endfor %}


services:
  server:
    image: itzg/minecraft-server:latest
    hostname: minecraft
    networks:
      - minecraft
    ports:
      - published: {{ app.ports.25565 }}
        target: 25565
        protocol: tcp
        mode: ingress
    volumes:
      - type: volume
        source: minecraft-data
        target: /data
        read_only: false
    environment:
      EULA: "TRUE"
      TZ: Americas/New_York
      VERSION: {{ app.versions.server }}
      MAX_MEMORY: "8G"
      MOTD: "A home for buttery companions"
      MODE: survival
      OPS: {{ app.settings.admins | default([]) | join(',') }}
      WHITELIST: "{{ app.settings.users | default([]) | join(',') }}"
      MAX_BUILD_HEIGHT: "512"
      SNOOPER_ENABLED: "false"
      ICON: https://cdn.enp.one/img/logos/e-w-sm.png
      ENABLE_RCON: "false"
      UID: "{{ _app_account.uid }}"
      GID: "{{ _app_account.uid }}"
    deploy:
      replicas: 1
