Skip to content

Instantly share code, notes, and snippets.

@mmornati
Last active Sep 8, 2021
Embed
What would you like to do?
default.yaml
# ===================================================================== #
# BASIC CONFIGURATION
# ===================================================================== #
# Arch: "default", "x86_64", "aarch64".
# "default" corresponds to the host architecture.
arch: "default"
# An image must support systemd and cloud-init.
# Ubuntu and Fedora are known to work.
# Default: none (must be specified)
images:
# Try to use a local image first.
- location: "~/Downloads/hirsute-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "~/Downloads/hirsute-server-cloudimg-arm64.img"
arch: "aarch64"
# Download the file from the internet when the local file is missing.
# Hint: run `limactl prune` to invalidate the "current" cache
- location: "https://cloud-images.ubuntu.com/hirsute/current/hirsute-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/hirsute/current/hirsute-server-cloudimg-arm64.img"
arch: "aarch64"
# CPUs: if you see performance issues, try limiting cpus to 1.
# Default: 4
cpus: 4
# Memory size
# Default: "4GiB"
memory: "4GiB"
# Disk size
# Default: "100GiB"
disk: "100GiB"
# Expose host directories to the guest
# Default: none
mounts:
- location: "~"
# CAUTION: `writable` SHOULD be false for the home directory.
# Setting `writable` to true is possible, but untested and dangerous.
writable: false
- location: "/tmp/lima"
writable: true
ssh:
# A localhost port of the host. Forwarded to port 22 of the guest.
# Currently, this port number has to be specified manually.
# Default: none
localPort: 60022
# Load ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub .
# This option is useful when you want to use other SSH-based
# applications such as rsync with the Lima instance.
# If you have an insecure key under ~/.ssh, do not use this option.
# Default: true
loadDotSSHPubKeys: true
# ===================================================================== #
# ADVANCED CONFIGURATION
# ===================================================================== #
containerd:
# Enable system-wide (aka rootful) containerd and its dependencies (BuildKit, Stargz Snapshotter)
# Default: false
system: false
# Enable user-scoped (aka rootless) containerd and its dependencies
# Default: true
user: true
# Provisioning scripts need to be idempotent because they might be called
# multiple times, e.g. when the host VM is being restarted.
provision:
# `system` is executed with the root privilege
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
if ! apt list --installed | grep docker-ce; then
curl -fsSL https://get.docker.com | sh -
sudo cat <<EOF > /etc/profile.d/docker.sh
#!/bin/bash
export DOCKER_HOST=unix:///run/user/\$(id -u)/docker.sock
EOF
else
echo "Docker already installed"
fi
if ! apt list --installed | grep google-cloud-sdk; then
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
apt-get update && apt-get install -y google-cloud-sdk
else
echo "Google Cloud already installed"
fi
# `user` is executed without the root privilege
- mode: user
script: |
#!/bin/bash
set -eux -o pipefail
dockerd-rootless-setuptool.sh install
if ! grep DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS ~/.config/systemd/user/docker.service; then
/usr/bin/sed -i '/Environment=.*/a Environment=DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="-p 0.0.0.0:2375:2375/tcp"' ~/.config/systemd/user/docker.service
/usr/bin/sed -i "s/ExecStart=.*/ExecStart=\/usr\/bin\/dockerd-rootless.sh -H unix:\/\/\/run\/user\/$(id -u)\/docker.sock -H tcp:\/\/0.0.0.0:2375/g" ~/.config/systemd/user/docker.service
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.0.0-rc.3/docker-compose-linux-amd64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
else
echo "Docker service already configured"
fi
/usr/bin/systemctl --user daemon-reload
/usr/bin/systemctl --user restart docker.service
gcloud auth configure-docker --quiet
probes:
# Only `readiness` probes are supported right now.
- mode: readiness
description: docker-ce to be installed
script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 90s bash -c "until command -v docker; do sleep 3; done"; then
echo >&2 "docker is not installed yet"
exit 1
fi
hint: |
docker was not installed in the guest. Make sure the package system is working correctly.
Also see "/var/log/cloud-init-output.log" in the guest.
- mode: readiness
description: gcloud to be installed
script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 90s bash -c "until command -v gcloud; do sleep 3; done"; then
echo >&2 "gcloud is not installed yet"
exit 1
fi
hint: |
gcloud was not installed in the guest. Make sure the package system is working correctly.
Also see "/var/log/cloud-init-output.log" in the guest.
- mode: readiness
description: rootless docker configured
script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 90s bash -c "until [ -f $(cat /etc/passwd | grep bash | grep -v root | cut -d: -f6)/.config/systemd/user/docker.service ]; do sleep 3; done"; then
echo >&2 "docker rootless is not configured yet"
exit 1
fi
hint: |
docker rootless is not configured in the guest. Make sure user scripts run
Also see "/var/log/cloud-init-output.log" in the guest.
# ===================================================================== #
# FURTHER ADVANCED CONFIGURATION
# ===================================================================== #
firmware:
# Use legacy BIOS instead of UEFI.
# Default: false
legacyBIOS: false
video:
# QEMU display, e.g., "none", "cocoa", "sdl".
# As of QEMU v5.2, enabling this is known to have negative impact
# on performance on macOS hosts: https://gitlab.com/qemu-project/qemu/-/issues/334
# Default: "none"
display: "none"
network:
# The instance can get routable IP addresses from the vmnet framework using
# https://github.com/lima-vm/vde_vmnet. Both vde_switch and vde_vmnet
# daemons must be running before the instance is started. The interface type
# (host, shared, or bridged) is configured in vde_vmnet and not lima.
vde:
# vnl (virtual network locator) points to the vde_switch socket directory,
# optionally with vde:// prefix
# - vnl: "vde:///var/run/vde.ctl"
# # VDE Switch port number (not TCP/UDP port number). Set to 65535 for PTP mode.
# # Default: 0
# switchPort: 0
# # MAC address of the instance; lima will pick one based on the instance name,
# # so DHCP assigned ip addresses should remain constant over instance restarts.
# macAddress: ""
# # Interface name, defaults to "vde0", "vde1", etc.
# name: ""
# Port forwarding rules. Forwarding between ports 22 and ssh.localPort cannot be overridden.
# Rules are checked sequentially until the first one matches.
portForwards:
- guestPort: 2375
hostIP: "127.0.0.1" # overrides the default value "127.0.0.1"; allows privileged port forwarding
# # default: hostPort: 443 (same as guestPort)
# # default: guestIP: "127.0.0.1" (also matches bind addresses "0.0.0.0", "::", and "::1")
# # default: proto: "tcp" (only valid value right now)
# - guestPortRange: [4000, 4999]
# hostIP: "0.0.0.0" # overrides the default value "127.0.0.1"
# # default: hostPortRange: [4000, 4999] (must specify same number of ports as guestPortRange)
# - guestPort: 80
# hostPort: 8080 # overrides the default value 80
# - guestIP: "127.0.0.2" # overrides the default value "127.0.0.1"
# hostIP: "127.0.0.2" # overrides the default value "127.0.0.1"
# # default: guestPortRange: [1024, 65535]
# # default: hostPortRange: [1024, 65535]
# - guestPort: 8888
# ignore: true (don't forward this port)
# # Lima internally appends this fallback rule at the end:
# - guestIP: "127.0.0.1"
# guestPortRange: [1024, 65535]
# hostIP: "127.0.0.1"
# hostPortRange: [1024, 65535]
# # Any port still not matched by a rule will not be forwarded (ignored)
# Extra environment variables that will be loaded into the VM at start up.
# These variables are currently only consumed by internal init scripts, not by the user shell.
# This field is experimental and may change in a future release of Lima.
# https://github.com/lima-vm/lima/pull/200
# env:
# KEY: value
# ===================================================================== #
# END OF TEMPLATE
# ===================================================================== #
@aesteve

This comment has been minimized.

Copy link

@aesteve aesteve commented Sep 8, 2021

Suggestion: add this somewhere

      if ! apt list --installed | grep docker-compose; then
        apt-get install -y docker-compose
      else 
        echo "Docker-Compose already installed"
      fi
@mmornati

This comment has been minimized.

Copy link
Owner Author

@mmornati mmornati commented Sep 8, 2021

Suggestion: add this somewhere

      if ! apt list --installed | grep docker-compose; then
        apt-get install -y docker-compose
      else 
        echo "Docker-Compose already installed"
      fi

Thanks @aesteve. I added in docker cli like the docker-desktop is doing in the latest version. Compose is now directly inside docker using docker compose. And we can add an alias alias docker-compose=docker compose if we want to keep both two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment