Skip to content

Commit 8e8d439

Browse files
committed
Use hcloud-upload-image for Hetzner imports
1 parent 13d52ee commit 8e8d439

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

.github/workflows/image-build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ jobs:
4646
- name: Import image into Hetzner
4747
env:
4848
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
49-
IMAGE_NAME: ${{ secrets.IMAGE_NAME }}
50-
IMAGE_DESCRIPTION: ${{ secrets.IMAGE_DESCRIPTION }}
49+
HCLOUD_LOCATION: nbg1
5150
run: scripts/import-image.sh "${IMAGE_URL}"

AGENTS.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,32 @@ Memory references:
1515

1616
Repo rule: no inline scripting languages (Python/Node/etc.) in Nix or shell blocks; put logic in script files and call them.
1717

18+
The Zen of ~~Python~~ Clawdbot, ~~by~~ shamelessly stolen from Tim Peters:
19+
- Beautiful is better than ugly.
20+
- Explicit is better than implicit.
21+
- Simple is better than complex.
22+
- Complex is better than complicated.
23+
- Flat is better than nested.
24+
- Sparse is better than dense.
25+
- Readability counts.
26+
- Special cases aren't special enough to break the rules.
27+
- Although practicality beats purity.
28+
- Errors should never pass silently.
29+
- Unless explicitly silenced.
30+
- In the face of ambiguity, refuse the temptation to guess.
31+
- There should be one-- and preferably only one --obvious way to do it.
32+
- Although that way may not be obvious at first unless you're Dutch.
33+
- Now is better than never.
34+
- Although never is often better than *right* now.
35+
- If the implementation is hard to explain, it's a bad idea.
36+
- If the implementation is easy to explain, it may be a good idea.
37+
- Namespaces are one honking great idea -- let's do more of those!
38+
1839
Deploy flow (automation-first):
1940
- Use `devenv.nix` for tooling (hcloud, nixos-generators, zstd).
2041
- Build a bootstrap NixOS image with nixos-generators (raw-efi), compress it, and upload to a public URL.
2142
- Use `nix/hosts/clawdinator-1-image.nix` for image builds.
22-
- CI is preferred: `.github/workflows/image-build.yml` runs build → S3 upload → Hetzner import.
43+
- CI is preferred: `.github/workflows/image-build.yml` runs build → S3 upload → Hetzner import (via `hcloud-upload-image`).
2344
- Bootstrap S3 bucket + scoped IAM user with `infra/opentofu/aws` (use homelab-admin creds).
2445
- Import the image into Hetzner with `hcloud image create`.
2546
- Provision host with OpenTofu (`infra/opentofu`; set `HCLOUD_TOKEN`, no tfvars with secrets).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Image-based deploy (Option A, recommended):
5252
- `zstd dist/nixos.img -o dist/nixos.img.zst`
5353
3) Upload the image to S3 (private object; use a presigned URL for import).
5454
4) Import into Hetzner:
55-
- `hcloud image create --from-url <url> --type custom --architecture x86 --name clawdinator-nixos`
55+
- Use `hcloud-upload-image` (Hetzner Cloud does not support direct URL imports).
5656
5) Point OpenTofu at the image name or id and provision.
5757
6) Re-key agenix secrets to the new host SSH key and sync secrets to `/var/lib/clawd/nix-secrets`.
5858
7) Run `nixos-rebuild switch --flake /var/lib/clawd/repo#clawdinator-1`.

docs/POC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Secrets wiring:
1818
- Infra: HCLOUD_TOKEN env var for OpenTofu and hcloud CLI.
1919

2020
Image pipeline:
21-
- Build a bootstrap image with nixos-generators (raw-efi) from `nix/hosts/clawdinator-1-image.nix`, compress, upload, import into Hetzner.
21+
- Build a bootstrap image with nixos-generators (raw-efi) from `nix/hosts/clawdinator-1-image.nix`, compress, upload, import into Hetzner using `hcloud-upload-image`.
2222
- OpenTofu provisions instances from the imported custom image, then nixos-rebuild applies full config.
2323
- Runtime: explicit token files via agenix (standard).
2424
- GitHub token is required. Prefer GitHub App (`services.clawdinator.githubApp.*`) to mint short-lived tokens.

scripts/import-image.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ if [ -z "${image_url}" ]; then
77
exit 1
88
fi
99

10-
name="${IMAGE_NAME:-clawdinator-nixos-$(date -u +%Y%m%d-%H%M%S)}"
11-
description="${IMAGE_DESCRIPTION:-CLAWDINATOR NixOS image}"
10+
location="${HCLOUD_LOCATION:-nbg1}"
1211

13-
hcloud image create \
14-
--from-url "${image_url}" \
15-
--type custom \
12+
docker run --rm \
13+
-e HCLOUD_TOKEN="${HCLOUD_TOKEN:?HCLOUD_TOKEN required}" \
14+
ghcr.io/apricote/hcloud-upload-image:latest \
15+
upload \
16+
--image-url "${image_url}" \
1617
--architecture x86 \
17-
--name "${name}" \
18-
--description "${description}"
18+
--compression zstd \
19+
--location "${location}"

0 commit comments

Comments
 (0)