Make each Coder template self-contained (fix coder templates push failure)
Provision Coder Templates / provision (push) Successful in 2m10s
Provision Coder Templates / provision (push) Successful in 2m10s
coder templates push -d templates/<env> only uploads that directory to the
Coder server, so main.tf's file() references reaching outside it via
../../profile-templates and ../../scripts failed at push/apply time
("Invalid function argument ... this function works only with files that
are distributed as part of the configuration source code"). Confirmed via
an actual failed run of coder-templates.yml once the runner network fix let
it get that far.
Fix: duplicate profile.code-profile, cli-setup-wizard.sh, and
install-skills.sh into each templates/<env>/ directory and drop the old
shared scripts/ and profile-templates/ directories.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,25 +9,34 @@ do and which didn't actually work.
|
||||
|
||||
```
|
||||
templates/
|
||||
default/main.tf # Standard Default Dev
|
||||
3d-printing/main.tf # 3D Printing & Engineering
|
||||
cobol/main.tf # COBOL Modern Mainframe
|
||||
python/main.tf # Python Engineering
|
||||
ttrpg/main.tf # TTRPG & Lore Building
|
||||
web/main.tf # Web Applications
|
||||
scripts/
|
||||
cli-setup-wizard.sh # shared first-run wizard, see below
|
||||
install-skills.sh # shared Agent Skills installer, see below
|
||||
profile-templates/ # VS Code .code-profile exports, one per env
|
||||
default/
|
||||
main.tf # Standard Default Dev
|
||||
profile.code-profile # VS Code .code-profile export for this env
|
||||
cli-setup-wizard.sh # first-run wizard, see below
|
||||
install-skills.sh # Agent Skills installer, see below
|
||||
3d-printing/ (same 4 files) # 3D Printing & Engineering
|
||||
cobol/ (same 4 files) # COBOL Modern Mainframe
|
||||
python/ (same 4 files) # Python Engineering
|
||||
ttrpg/ (same 4 files) # TTRPG & Lore Building
|
||||
web/ (same 4 files) # Web Applications
|
||||
extensions/ # Agent Skills bundles, installed per env (see below)
|
||||
```
|
||||
|
||||
Each `templates/<env>/main.tf` is a complete, independent Coder template
|
||||
(agent, docker container, code-server, JetBrains). They're deliberately not
|
||||
built from a shared Terraform module - only their `locals` block differs
|
||||
(which profile file to read). The naming convention is `profiles-<dir>`
|
||||
(matches what `.gitea/workflows/coder-templates.yml` does automatically -
|
||||
see below). To push by hand:
|
||||
Each `templates/<env>/` is a complete, independent Coder template (agent,
|
||||
docker container, code-server, JetBrains) with its own copy of everything
|
||||
`main.tf` needs. They're deliberately not built from a shared Terraform
|
||||
module or shared files elsewhere in the repo: `coder templates push -d
|
||||
templates/<env>` only uploads that one directory to the Coder server, so any
|
||||
`file()` reference reaching outside it (e.g. the old shared
|
||||
`scripts/`/`profile-templates/` layout) fails at push/apply time with
|
||||
`Invalid function argument: ... this function works only with files that
|
||||
are distributed as part of the configuration source code` - discovered the
|
||||
hard way once `coder-templates.yml` actually ran end-to-end. `main.tf`,
|
||||
`profile.code-profile`, `cli-setup-wizard.sh`, and `install-skills.sh` are
|
||||
duplicated per template rather than shared for this reason; only their
|
||||
`locals` block and profile file differ meaningfully. The naming convention
|
||||
is `profiles-<dir>` (matches what `.gitea/workflows/coder-templates.yml`
|
||||
does automatically - see below). To push by hand:
|
||||
|
||||
```sh
|
||||
coder templates push profiles-default -d templates/default
|
||||
@@ -40,7 +49,7 @@ coder templates push profiles-web -d templates/web
|
||||
|
||||
### How the VS Code profile gets applied
|
||||
|
||||
`profile-templates/*.code-profile` is a real VS Code Profile export: a JSON
|
||||
`templates/<env>/profile.code-profile` is a real VS Code Profile export: a JSON
|
||||
file whose `settings` and `extensions` fields are themselves JSON-encoded
|
||||
strings (double/triple-nested). Each template's `main.tf` reads and decodes
|
||||
its matching file **at `terraform apply`/push time** (via `file()` +
|
||||
@@ -71,7 +80,8 @@ installs.
|
||||
|
||||
### CLI setup wizard
|
||||
|
||||
`scripts/cli-setup-wizard.sh` is dropped onto every workspace and hooked
|
||||
`templates/<env>/cli-setup-wizard.sh` (identical across envs) is dropped
|
||||
onto every workspace and hooked
|
||||
into `~/.bashrc`. It runs in every new interactive terminal - until the user
|
||||
finishes it - and offers to install + log into:
|
||||
|
||||
@@ -92,7 +102,7 @@ root `main.tf` copied this folder straight into code-server's VS Code
|
||||
extensions directory, which never worked since these aren't VS Code
|
||||
extension packages.
|
||||
|
||||
Each template now runs `scripts/install-skills.sh` (via a `coder_script`,
|
||||
Each template now runs its own copy of `install-skills.sh` (via a `coder_script`,
|
||||
pulling a fresh zip of this repo from Gitea rather than embedding ~2.5MB
|
||||
into Terraform state) to install skills into all three AI CLIs' personal
|
||||
skills directories:
|
||||
@@ -117,13 +127,13 @@ the `SPECIALTY_SKILLS` env var passed to the script from each template's
|
||||
### Auto-provisioning (Gitea Actions)
|
||||
|
||||
`.gitea/workflows/coder-templates.yml` keeps Coder in sync with this repo on
|
||||
every push to `main` that touches `templates/**`, `scripts/**`, or
|
||||
`profile-templates/**`:
|
||||
every push to `main` that touches `templates/**`:
|
||||
|
||||
- **Add** a new `templates/<env>/` directory -> next push creates a new
|
||||
Coder template `profiles-<env>` automatically. No workflow edits needed.
|
||||
- **Edit** an existing `templates/<env>/main.tf` (or a shared script/profile
|
||||
it references) -> next push updates that template with a new version.
|
||||
- **Edit** an existing `templates/<env>/main.tf` (or its `profile.code-profile`,
|
||||
`cli-setup-wizard.sh`, or `install-skills.sh`) -> next push updates that
|
||||
template with a new version.
|
||||
- **Remove** a `templates/<env>/` directory -> next push deletes
|
||||
`profiles-<env>` from Coder. `coder templates delete` refuses if the
|
||||
template still has active workspaces, so this fails loudly instead of
|
||||
|
||||
Reference in New Issue
Block a user