# This example requires Lima v0.7.0 or later.
images:
- location: "https://github.com/lima-vm/alpine-lima/releases/download/v0.2.13/alpine-lima-std-3.15.4-x86_64.iso"
  arch: "x86_64"
  digest: "sha512:1da1067355e4db7efb5ae6f827f6555480c1510f764f133c795e736a1fea020091d8bf6ad3cffd7f209c2987dfe41ba490f4796c5ea0be1052d8ac99b81d9bef"
- location: "https://github.com/lima-vm/alpine-lima/releases/download/v0.2.13/alpine-lima-std-3.15.4-aarch64.iso"
  arch: "aarch64"
  digest: "sha512:68fab773f96cc21ae2422ddcdade51392f4fd99ff8e1906c4912ac77945c58c022109098f25f5f3c11a94351b62419193cae04fc645fe35bf2eefb4bc51bb769"

mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true

provision:
- mode: system
  # This script defines the host.docker.internal hostname when hostResolver is disabled.
  # It is also needed for lima 0.8.2 and earlier, which does not support hostResolver.hosts.
  # Names defined in /etc/hosts inside the VM are not resolved inside containers when
  # using the hostResolver; use hostResolver.hosts instead (requires lima 0.8.3 or later).
  script: |
    #!/bin/sh
    sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts
- mode: system
  script: |
    #!/bin/sh
    set -eux -o pipefail
    command -v docker >/dev/null 2>&1 && exit 0
    apk update
    apk add docker
    rc-update add docker boot
    service docker start
- mode: user
  script: |
    #!/bin/sh
    set -eux -o pipefail
    sudo addgroup "$USER" docker
probes:
- script: |
    #!/bin/sh
    set -eux -o pipefail
    if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
      echo >&2 "docker is not installed yet"
      exit 1
    fi
hostResolver:
  # hostResolver.hosts requires lima 0.8.3 or later. Names defined here will also
  # resolve inside containers, and not just inside the VM itself.
  hosts:
    host.docker.internal: host.lima.internal
portForwards:
- guestSocket: "/var/run/docker.sock"
  hostSocket: "{{.Dir}}/sock/docker.sock"
message: |
  To run `docker` on the host (assumes docker-cli is installed), run the following commands:
  ------
  docker context create lima --docker "host=unix://{{.Dir}}/sock/docker.sock"
  docker context use lima
  docker run hello-world
  ------

firmware:
  legacyBIOS: true

# The built-in containerd installer does not support Alpine currently.
# Hint: use the "rd" ISO instead of the "std" ISO to enable containerd: https://github.com/lima-vm/alpine-lima/releases/
containerd:
  system: false
  user: false
