mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add lima incus example (#24640)
Depends on https://github.com/coder/coder/pull/24616 Adds a sample Lima configuration for Coder+Incus.
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ USAGE:
|
|||||||
Get started with a templated template.
|
Get started with a templated template.
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|docker-envbuilder|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|kubernetes-devcontainer|nomad-docker|scratch|tasks-docker
|
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|docker-envbuilder|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|incus|kubernetes|kubernetes-devcontainer|nomad-docker|scratch|tasks-docker
|
||||||
Specify a given example template by ID.
|
Specify a given example template by ID.
|
||||||
|
|
||||||
———
|
———
|
||||||
|
|||||||
Generated
+3
-3
@@ -13,8 +13,8 @@ coder templates init [flags] [directory]
|
|||||||
|
|
||||||
### --id
|
### --id
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
|------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| Type | <code>aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|digitalocean-linux\|docker\|docker-devcontainer\|docker-envbuilder\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|kubernetes\|kubernetes-devcontainer\|nomad-docker\|scratch\|tasks-docker</code> |
|
| Type | <code>aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|digitalocean-linux\|docker\|docker-devcontainer\|docker-envbuilder\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|incus\|kubernetes\|kubernetes-devcontainer\|nomad-docker\|scratch\|tasks-docker</code> |
|
||||||
|
|
||||||
Specify a given example template by ID.
|
Specify a given example template by ID.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -36,6 +36,7 @@ var (
|
|||||||
//go:embed templates/gcp-linux
|
//go:embed templates/gcp-linux
|
||||||
//go:embed templates/gcp-vm-container
|
//go:embed templates/gcp-vm-container
|
||||||
//go:embed templates/gcp-windows
|
//go:embed templates/gcp-windows
|
||||||
|
//go:embed templates/incus
|
||||||
//go:embed templates/kubernetes
|
//go:embed templates/kubernetes
|
||||||
//go:embed templates/kubernetes-devcontainer
|
//go:embed templates/kubernetes-devcontainer
|
||||||
//go:embed templates/nomad-docker
|
//go:embed templates/nomad-docker
|
||||||
|
|||||||
+29
-7
@@ -1,19 +1,22 @@
|
|||||||
---
|
---
|
||||||
name: Run Coder in Lima
|
name: Run Coder in Lima
|
||||||
description: Quickly stand up Coder using Lima
|
description: Quickly stand up Coder using Lima
|
||||||
tags: [local, docker, vm, lima]
|
tags: [local, docker, incus, vm, lima]
|
||||||
---
|
---
|
||||||
|
|
||||||
# Run Coder in Lima
|
# Run Coder in Lima
|
||||||
|
|
||||||
This provides a sample [Lima](https://github.com/lima-vm/lima) configuration for Coder.
|
This provides sample [Lima](https://github.com/lima-vm/lima) configurations for Coder.
|
||||||
This lets you quickly test out Coder in a self-contained environment.
|
This lets you quickly test out Coder in a self-contained environment.
|
||||||
|
The Docker configuration runs workspaces in Docker containers; the Incus configuration runs workspaces in Incus system containers (with Docker available inside each workspace).
|
||||||
|
|
||||||
> Prerequisite: You must have `lima` installed and available to use this.
|
> Prerequisite: You must have `lima` installed and available to use this.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started (Docker)
|
||||||
|
|
||||||
- Run `limactl start --name=coder https://raw.githubusercontent.com/coder/coder/main/examples/lima/coder.yaml`
|
This configuration (`coder-docker.yaml`) creates a VM to run Coder workspaces in Docker.
|
||||||
|
|
||||||
|
- Run `limactl start --name=coder https://raw.githubusercontent.com/coder/coder/main/examples/lima/coder-docker.yaml`
|
||||||
- You can use the configuration as-is, or edit it to your liking.
|
- You can use the configuration as-is, or edit it to your liking.
|
||||||
|
|
||||||
This will:
|
This will:
|
||||||
@@ -21,13 +24,32 @@ This will:
|
|||||||
- Start an Ubuntu 22.04 VM
|
- Start an Ubuntu 22.04 VM
|
||||||
- Install Docker and Terraform from the official repos
|
- Install Docker and Terraform from the official repos
|
||||||
- Install Coder using the [installation script](../../docs/install/install.sh.md)
|
- Install Coder using the [installation script](../../docs/install/install.sh.md)
|
||||||
- Generates an initial user account `admin@coder.com` with a randomly generated password (stored in the VM under `/home/${USER}.linux/.config/coderv2/password`)
|
- Generate an initial user account `admin@coder.com` with a randomly generated password (stored in the VM under `/home/${USER}.linux/.config/coderv2/password`)
|
||||||
- Initializes a [sample Docker template](https://github.com/coder/coder/tree/main/examples/templates/docker) for creating workspaces
|
- Initialize a [sample Docker template](https://github.com/coder/coder/tree/main/examples/templates/docker) for creating workspaces
|
||||||
|
|
||||||
Once this completes, you can visit `http://localhost:3000` and start creating workspaces!
|
Once this completes, you can visit `http://localhost:3000` and start creating workspaces!
|
||||||
|
|
||||||
Alternatively, enter the VM with `limactl shell coder` and run `coder templates init` to start creating your own templates!
|
Alternatively, enter the VM with `limactl shell coder` and run `coder templates init` to start creating your own templates!
|
||||||
|
|
||||||
|
## Getting Started (Incus)
|
||||||
|
|
||||||
|
This configuration (`coder-incus.yaml`) creates a VM to run Coder workspaces in Incus.
|
||||||
|
|
||||||
|
- Run `limactl start --name=coder-incus https://raw.githubusercontent.com/coder/coder/main/examples/lima/coder-incus.yaml`
|
||||||
|
- You can use the configuration as-is, or edit it to your liking.
|
||||||
|
|
||||||
|
This will:
|
||||||
|
|
||||||
|
- Start a Debian 13 VM
|
||||||
|
- Install Incus from the Debian repos and Terraform via the Coder installer
|
||||||
|
- Install Coder using the [installation script](../../docs/install/install.sh.md)
|
||||||
|
- Generate an initial user account `admin@coder.com` with a randomly generated password (stored in the VM under `/home/${USER}.linux/.config/coderv2/password`)
|
||||||
|
- Initialize a [sample Incus template](https://github.com/coder/coder/tree/main/examples/templates/incus) for creating workspaces
|
||||||
|
|
||||||
|
Once this completes, you can visit `http://localhost:3000` and start creating workspaces!
|
||||||
|
|
||||||
|
Alternatively, enter the VM with `limactl shell coder-incus` and run `coder templates init` to start creating your own templates!
|
||||||
|
|
||||||
## Further Information
|
## Further Information
|
||||||
|
|
||||||
- To learn more about Lima, [visit the the project's GitHub page](https://github.com/lima-vm/lima/).
|
- To learn more about Lima, [visit the project's GitHub page](https://github.com/lima-vm/lima/).
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Deploy Coder in Lima via the install script
|
# Deploy Coder in Lima with Docker via the install script
|
||||||
# See: https://coder.com/docs/install
|
# See: https://coder.com/docs/install
|
||||||
# $ limactl start ./coder.yaml
|
# $ limactl start ./coder-docker.yaml
|
||||||
# $ limactl shell coder
|
# $ limactl shell coder
|
||||||
# The web UI is accessible on http://localhost:3000 -- ports are forwarded automatically by lima:
|
# The web UI is accessible on http://localhost:3000. Ports are forwarded automatically by Lima.
|
||||||
# $ coder login http://localhost:3000
|
# $ coder login http://localhost:3000
|
||||||
|
|
||||||
# This example requires Lima v0.8.3 or later.
|
# This example requires Lima v0.8.3 or later.
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
# Deploy Coder in Lima with Incus
|
||||||
|
# See: https://coder.com/docs/install
|
||||||
|
# $ limactl start ./coder-incus.yaml
|
||||||
|
# $ limactl shell coder-incus
|
||||||
|
# The web UI is accessible on http://localhost:3000. Ports are forwarded automatically by Lima.
|
||||||
|
# $ coder login http://localhost:3000
|
||||||
|
|
||||||
|
minimumLimaVersion: "2.0.0"
|
||||||
|
|
||||||
|
images:
|
||||||
|
- location: "https://cloud.debian.org/images/cloud/trixie/20260327-2429/debian-13-genericcloud-amd64-20260327-2429.qcow2"
|
||||||
|
arch: "x86_64"
|
||||||
|
digest: "sha512:09559ec27d263997827dd8cddf76e97ea8e0f1803380aa501ea7eaa4b4968cd76ffef4ec7eb07ef1a9ccbeb0925a5020492ea9ed53eb167d62f3a2285039912c"
|
||||||
|
- location: "https://cloud.debian.org/images/cloud/trixie/20260327-2429/debian-13-genericcloud-arm64-20260327-2429.qcow2"
|
||||||
|
arch: "aarch64"
|
||||||
|
digest: "sha512:cb25e88240d8760c860f780c42257472f7c63c1ab54368c4eaa4ddb44e1e6224df8e719ee7ab0fb0d52d5de505f98034dd44ee73a9d9dcf66a2035215f1e8512"
|
||||||
|
# Fallback to the latest release image.
|
||||||
|
# Hint: run `limactl prune` to invalidate the cache
|
||||||
|
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-amd64-daily.qcow2"
|
||||||
|
arch: "x86_64"
|
||||||
|
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-arm64-daily.qcow2"
|
||||||
|
arch: "aarch64"
|
||||||
|
|
||||||
|
# Disable 9p mounts; they are not supported by the Debian cloud image kernel.
|
||||||
|
mountTypesUnsupported: [9p]
|
||||||
|
|
||||||
|
# Your home directory is mounted read-only
|
||||||
|
mounts:
|
||||||
|
- location: "~"
|
||||||
|
containerd:
|
||||||
|
system: false
|
||||||
|
user: false
|
||||||
|
provision:
|
||||||
|
- mode: system
|
||||||
|
script: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux -o pipefail
|
||||||
|
command -v incus >/dev/null 2>&1 && exit 0
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
# Wait for any apt locks from unattended-upgrades on first boot
|
||||||
|
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 1; done
|
||||||
|
# Incus is available natively in Debian Trixie
|
||||||
|
apt-get update
|
||||||
|
apt-get install -qqy incus btrfs-progs
|
||||||
|
# Initialize Incus with preseed config.
|
||||||
|
# We use an explicit subnet because --minimal's auto-detection fails
|
||||||
|
# when Lima's own bridge already claims the common ranges.
|
||||||
|
cat <<'PRESEED' | incus admin init --preseed
|
||||||
|
networks:
|
||||||
|
- name: incusbr0
|
||||||
|
type: bridge
|
||||||
|
config:
|
||||||
|
ipv4.address: 10.155.0.1/24
|
||||||
|
ipv4.nat: "true"
|
||||||
|
ipv6.address: none
|
||||||
|
storage_pools:
|
||||||
|
- name: coder
|
||||||
|
driver: btrfs
|
||||||
|
profiles:
|
||||||
|
- name: default
|
||||||
|
devices:
|
||||||
|
eth0:
|
||||||
|
name: eth0
|
||||||
|
network: incusbr0
|
||||||
|
type: nic
|
||||||
|
root:
|
||||||
|
path: /
|
||||||
|
pool: coder
|
||||||
|
type: disk
|
||||||
|
PRESEED
|
||||||
|
# Give the Lima user access to Incus
|
||||||
|
usermod -aG incus-admin {{.User}}
|
||||||
|
- mode: system
|
||||||
|
script: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux -o pipefail
|
||||||
|
command -v coder >/dev/null 2>&1 && exit 0
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export HOME=/root
|
||||||
|
# Wait for any apt locks from unattended-upgrades on first boot
|
||||||
|
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 1; done
|
||||||
|
# Using install.sh --with-terraform requires unzip to be available.
|
||||||
|
apt-get update
|
||||||
|
apt-get install -qqy unzip
|
||||||
|
curl -fsSL https://coder.com/install.sh | sh -s -- --with-terraform
|
||||||
|
# Ensure Coder has access to the Incus socket
|
||||||
|
usermod -aG incus-admin coder
|
||||||
|
# Ensure coder listens on all interfaces
|
||||||
|
sed -i 's/CODER_HTTP_ADDRESS=.*/CODER_HTTP_ADDRESS=0.0.0.0:3000/' /etc/coder.d/coder.env
|
||||||
|
# Also set the access URL to host.lima.internal for fast deployments
|
||||||
|
sed -i 's#CODER_ACCESS_URL=.*#CODER_ACCESS_URL=http://host.lima.internal:3000#' /etc/coder.d/coder.env
|
||||||
|
# Ensure coder starts on boot
|
||||||
|
systemctl enable coder
|
||||||
|
systemctl start coder
|
||||||
|
# Wait for Terraform to be installed
|
||||||
|
timeout 60s bash -c 'until /usr/local/bin/terraform version >/dev/null 2>&1; do sleep 1; done'
|
||||||
|
- mode: user
|
||||||
|
script: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux -o pipefail
|
||||||
|
# If we are already logged in, nothing to do
|
||||||
|
coder templates list >/dev/null 2>&1 && exit 0
|
||||||
|
# Set up initial user
|
||||||
|
[ ! -e ~/.config/coderv2/session ] && coder login http://localhost:3000 \
|
||||||
|
--first-user-username admin \
|
||||||
|
--first-user-email admin@coder.com \
|
||||||
|
--first-user-password "$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12 | tee ${HOME}/.config/coderv2/password)"
|
||||||
|
# Create an initial Incus template
|
||||||
|
coder templates init --id incus
|
||||||
|
pushd ./incus
|
||||||
|
coder templates push incus --yes
|
||||||
|
popd
|
||||||
|
rm -rf ./incus
|
||||||
|
probes:
|
||||||
|
- description: "incus to be installed"
|
||||||
|
script: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux -o pipefail
|
||||||
|
if ! timeout 30s bash -c "until command -v incus >/dev/null 2>&1; do sleep 3; done"; then
|
||||||
|
echo >&2 "incus is not installed yet"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
hint: |
|
||||||
|
See `/var/log/lima-guestagent.log` or run `limactl shell coder-incus` to debug.
|
||||||
|
- description: "coder to be installed"
|
||||||
|
script: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -eux -o pipefail
|
||||||
|
if ! timeout 30s bash -c "until command -v coder >/dev/null 2>&1; do sleep 3; done"; then
|
||||||
|
echo >&2 "coder is not installed yet"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
hint: |
|
||||||
|
See `/var/log/lima-guestagent.log` or run `limactl shell coder-incus` to debug.
|
||||||
|
message: |
|
||||||
|
All Done! Your Coder instance is accessible at http://localhost:3000
|
||||||
|
|
||||||
|
Username: "admin@coder.com"
|
||||||
|
Password: Run `LIMA_INSTANCE={{.Instance.Name}} lima cat /home/${USER}.linux/.config/coderv2/password`
|
||||||
|
|
||||||
|
Create your first workspace:
|
||||||
|
------
|
||||||
|
limactl shell {{.Instance.Name}}
|
||||||
|
coder create my-workspace --template incus
|
||||||
|
------
|
||||||
|
|
||||||
|
Get started creating your own template now:
|
||||||
|
------
|
||||||
|
limactl shell {{.Instance.Name}}
|
||||||
|
cd && coder templates init
|
||||||
|
------
|
||||||
Reference in New Issue
Block a user