-
Notifications
You must be signed in to change notification settings - Fork 900
add lima template for coder #2452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5944d4d
4eb46b1
0690ba7
5782c86
4094b02
71a54e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: Run Coder in Lima | ||
description: Quickly stand up Coder using Lima | ||
tags: [local, docker, vm, lima] | ||
--- | ||
|
||
# Lima VM Template | ||
|
||
This provides a [Lima](https://github.com/lima-vm/lima) template for Coder. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: We might not want to call this "template" to avoid confusion with actual coder templates (and
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This lets you quickly test out Coder in a self-contained environment. | ||
|
||
> Prerequisite: You must have `lima` installed and available to use this. | ||
|
||
## Getting Started | ||
|
||
- Run `limactl start --name=coder https://raw.githubusercontent.com/coder/coder/main/examples/lima/coder.yaml` | ||
- You can use the configuration as-is, or edit it to your liking. | ||
|
||
This will: | ||
- Start an Ubuntu 22.04 VM | ||
- Install Docker from the official repos | ||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Install Coder using the [installation script](https://coder.com/docs/coder-oss/latest/install#installsh) | ||
- Generates 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-code-server) for 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 template init` to start creating your own templates! | ||
|
||
## Further Information | ||
|
||
- To learn more about Lima, [visit the the project's GitHub page](https://github.com/lima-vm/lima/). |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -58,6 +58,17 @@ provision: | |||||
systemctl restart docker | ||||||
# In case a user forgets to set the arch correctly, just install binfmt | ||||||
docker run --privileged --rm tonistiigi/binfmt --install all | ||||||
- mode: system | ||||||
script: | | ||||||
#!/bin/bash | ||||||
set -eux -o pipefail | ||||||
command -v terraform >/dev/null 2>&1 && exit 0 | ||||||
wget -qO - terraform.gpg https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/terraform-archive-keyring.gpg | ||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/terraform.list | ||||||
export DEBIAN_FRONTEND=noninteractive | ||||||
apt-get update -y | ||||||
apt-get install terraform=1.1.9 | ||||||
apt-mark hold terraform | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
- mode: system | ||||||
script: | | ||||||
#!/bin/bash | ||||||
|
@@ -79,8 +90,18 @@ provision: | |||||
set -eux -o pipefail | ||||||
# If we are already logged in, nothing to do | ||||||
coder templates list >/dev/null 2>&1 && exit 0 | ||||||
# Wait for Coder to become available | ||||||
timeout 30s bash -c 'until nc -z localhost 3000; do sleep 1; done' | ||||||
# Set up initial user | ||||||
[ ! -e ~/.config/coderv2/session ] && coder login http://localhost:3000 --username admin --email admin@coder.com --password password | ||||||
[ ! -e ~/.config/coderv2/session ] && coder login http://localhost:3000 --username admin --email admin@coder.com --password $(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8 | tee ${HOME}/.config/coderv2/password) | ||||||
# Create an initial template | ||||||
cd ${HOME} | ||||||
echo code-server | coder templates init | ||||||
cd ./docker-code-server | ||||||
if [ $(arch) = "aarch64" ]; then | ||||||
sed -i 's/arch.*=.*"amd64"/arch = "arm64"/' ./main.tf | ||||||
fi | ||||||
coder templates create docker-code-server -y -d . | ||||||
probes: | ||||||
- description: "docker to be installed" | ||||||
script: | | ||||||
|
@@ -102,25 +123,15 @@ probes: | |||||
fi | ||||||
hint: | | ||||||
See "/var/log/cloud-init-output.log". in the guest | ||||||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- description: "terraform to be fully downloaded" | ||||||
script: | | ||||||
#!/bin/bash | ||||||
set -eux -o pipefail | ||||||
if ! timeout 30s bash -c "until [ $(du /var/cache/coder/terraform | awk '{print $1}') -ge 62784 ] >/dev/null 2>&1; do sleep 3; done"; then | ||||||
echo >&2 "terraform is not fully downloaded yet" | ||||||
exit 1 | ||||||
fi | ||||||
hint: | | ||||||
Check "/var/cache/coder/terraform" in the guest | ||||||
message: | | ||||||
All Done! Your Coder instance is accessible at http://localhost:3000 | ||||||
|
||||||
Username: "admin@coder.com" | ||||||
Password: "password" 🤫 | ||||||
Start a workspace now by running the following commands: | ||||||
Password: `LIMA_INSTANCE=coder lima cat /home/${USER}.linux/.config/coderv2/password` 🤫 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Minor suggestion, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, it doesn't execute in the output, it's more of an indication for the user to run it 😅
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Get started creating your own template now: | ||||||
------ | ||||||
limactl shell coder | ||||||
cd && echo code-server | coder templates init | ||||||
cd ./docker-code-server && coder templates create -y | ||||||
coder create -t docker-code-server my-workspace -y | ||||||
cd && coder templates init | ||||||
------ | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.