{
  "variables": {
    "do_api_token": "{{env `DIGITALOCEAN_API_TOKEN`}}",
    "image_name": "wikijs-snapshot-{{timestamp}}",
    "apt_packages": "software-properties-common",
    "application_name": "Wiki.js",
    "application_version": "{{env `WIKI_APP_VERSION`}}"
  },
  "sensitive-variables": [
    "do_api_token"
  ],
  "builders": [
    {
      "type": "digitalocean",
      "api_token": "{{user `do_api_token`}}",
      "image": "ubuntu-24-04-x64",
      "region": "tor1",
      "size": "s-1vcpu-1gb",
      "ssh_username": "root",
      "snapshot_name": "{{user `image_name`}}"
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "cloud-init status --wait"
      ]
    },
    {
      "type": "file",
      "source": "scripts/001-onboot.sh",
      "destination": "/var/lib/cloud/scripts/per-instance/001-onboot.sh"
    },
    {
      "type": "file",
      "source": "scripts/099-one-click",
      "destination": "/etc/update-motd.d/099-one-click"
    },
    {
      "type": "shell",
      "inline": [
        "chmod +x /var/lib/cloud/scripts/per-instance/001-onboot.sh",
        "chmod +x /etc/update-motd.d/099-one-click"
      ]
    },
    {
      "type": "shell",
      "environment_vars": [
        "DEBIAN_FRONTEND=noninteractive",
        "LC_ALL=C",
        "LANG=en_US.UTF-8",
        "LC_CTYPE=en_US.UTF-8"
      ],
      "inline": [
        "apt -qqy update",
        "apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade",
        "apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install {{user `apt_packages`}}",
        "apt-get -qqy clean"
      ]
    },
    {
      "type": "shell",
      "environment_vars": [
        "application_name={{user `application_name`}}",
        "application_version={{user `application_version`}}",
        "docker_compose_version={{user `docker_compose_version`}}",
        "DEBIAN_FRONTEND=noninteractive",
        "LC_ALL=C",
        "LANG=en_US.UTF-8",
        "LC_CTYPE=en_US.UTF-8"
      ],
      "scripts": [
        "scripts/010-docker.sh",
        "scripts/011-ufw-docker.sh",
        "scripts/020-force-ssh-logout.sh",
        "scripts/900-cleanup.sh",
        "scripts/999-img-check.sh"
      ]
    }
  ]
}
