#cloud-config

package_update: true
package_upgrade: true
package_reboot_if_required: true

# https://packages.debian.org/bookworm/docker.io
packages:
  - ca-certificates
  - curl
  - docker.io
  - docker-compose
  # https://stackoverflow.com/a/74084180
  - apparmor

# https://docs.coopcloud.tech/operators/tutorial/#server-setup
runcmd:
  - curl -fsSL https://install.abra.coopcloud.tech | env HOME=/root bash
  - docker swarm init
  - docker network create -d overlay proxy

write_files:
  # Add abra to PATH and set EDITOR
  - path: /etc/profile.d/custom_path.sh
    content: |
      export PATH=$PATH:$HOME/.local/bin
      export EDITOR=vim
    owner: root:root
    permissions: '0755'
  # Send container log to journald: https://docs.coopcloud.tech/operators/handbook/#how-do-i-persist-container-logs-after-they-go-away
  - path: /etc/docker/daemon.json
    content: |
      {
          "log-driver": "journald",
          "log-opts": {
            "labels":"com.docker.swarm.service.name"
          }
      }
    owner: root:root
    permissions: '0644'
  # Rotate logs
  - path: /etc/systemd/journald.conf
    content: |
      [Journal]
      Storage=persistent
      SystemMaxUse=5G
      MaxFileSec=1month
    owner: root:root
    permissions: '0644'
