Files
coder/coderd/templatebuilder/bases/quickstart/install-languages.sh.tftpl
T
Nick Vigilante c78dca5141 feat: add Coder Quickstart base to the template builder (#27247)
## Summary

Adds the **Coder Quickstart** template as a selectable base in the
[template builder](coderd/templatebuilder) guided wizard. It is a
Docker-based starter that lets a user pick languages and optionally
clone a repo.

## What changed

- **New base package** `coderd/templatebuilder/bases/quickstart/`:
- `base.json`: `id: "quickstart"`, `display_name: "Coder Quickstart"`,
`os: "linux"`.
- `main.tf.tmpl`: a Docker workspace with a language selector, a single
language-install script, an optional Git clone, and workspace presets.
Editors are added via the builder's module step rather than baked into
the base.
- `install-languages.sh.tftpl` and `README.md` (with prerequisites
markers so the builder can extract the prerequisites section).
- **Placement**: the bases endpoint returns a plain list sorted by
display name (with ID as a deterministic tiebreak). The wizard's
base-infra select step prioritizes the Quickstart and Docker starters to
the front on the client, mirroring the existing client-side module
prioritization in `ModuleSelectStep` (shared `sortByPriority` helper).
- **Base/module collision guard**: a base's bundled catalog modules are
derived from its rendered Terraform (`ExtractModuleNames`, cached with
`sync.OnceValues` and filtered to catalog IDs). `validateModules` seeds
its seen-set from that derived set, so a wizard-selected module the base
already renders is rejected with a clear error, and the modules endpoint
omits it so the wizard never offers a colliding module. The base's
Terraform is the single source of truth, so there is no separate
manifest list that can drift.

## Testing

- `go test ./coderd/` (template builder handler: bases ordering, the
`baseSpec` table, the modules-endpoint base filter): pass.
- `go test ./coderd/templatebuilder/` (all-bases render/snapshot, the
collision guard, `TestBaseIncludedModules`, the selector/install-script
drift test): pass.
- `gofmt`, `go vet`, `golangci-lint`: clean.
- Frontend `tsc`, `biome`, and `knip`: clean.

## Review decisions

- **Template scope**: trimmed to infrastructure, a language selector,
and an optional Git clone. The IDE selector was removed; editors are
added via the builder's module step.
- **Placement**: base ordering is presentational, so it lives on the
client base-infra select step rather than in the API.
- **git-clone in the base**: kept for the build-time clone affordance.
The base renders its module source verbatim, so it currently pins the
public registry and does not yet honor a deployment's registry mirror;
that fix is tracked in DOCS-610 and delivered as a stacked follow-up PR
(an in-code note documents the current behavior).
- **Container image**: left hardcoded
(`codercom/enterprise-base:ubuntu`). The quickstart base is the
opinionated path; the Docker base covers custom images. Revisiting a
`container_image` variable is tracked in DOCS-611.

## Review updates (@jeremyruppel)

- **Ordering moved to the client**: deleted the server-side
Quickstart-before-Docker grouping (and its position test); the
base-infra select step now prioritizes bases client-side via a shared
`sortByPriority` helper, following the `ModuleSelectStep` precedent. The
API just returns a stable, name-sorted list.
- **Derive included modules from render**: dropped the
`included_modules` manifest field and the `IncludedModules` struct
field; `BaseIncludedModules` now derives from the rendered base (single
source of truth). Removed `TestBaseIncludedModulesMatchRendered` and
added a direct `TestBaseIncludedModules`.
- **Kept the PR scoped to "add quickstart base"**: reverted
`ExtractAgentResourceName`/`ExtractModuleNames` to the pre-`hclsyntax`
regex extraction and removed the option/preset HCL extractor family; the
selector↔install-script drift test now uses a small regex. The broader
templatebuilder HCL migration and the preset-language subset guard are
tracked in DOCS-735.
- Branch rebased onto `origin/main` (no content changes beyond the
above).

---

Linear:
[DOCS-558](https://linear.app/codercom/issue/DOCS-558/add-coder-quickstart-template-to-template-builder)

> This PR was created with AI assistance (Coder Agents).
2026-08-26 20:29:20 -04:00

99 lines
2.8 KiB
Plaintext

#!/bin/bash
set -e
LANGUAGES="${LANGUAGES}"
APT_UPDATED=false
apt_update() {
if [ "$APT_UPDATED" = "false" ]; then
sudo apt-get update -qq
APT_UPDATED=true
fi
}
# has_language reports whether NAME is one of the selected languages. It matches
# whole comma-separated entries, so a value can never partially match another
# (guards against a future language whose name contains an existing one).
has_language() {
case ",$LANGUAGES," in
*",$1,"*) return 0 ;;
*) return 1 ;;
esac
}
if has_language python; then
if command -v python3 >/dev/null 2>&1; then
echo "Python: $(python3 --version)"
else
echo "Installing Python..."
apt_update
sudo apt-get install -y -qq python3 python3-pip python3-venv
echo "Installed Python: $(python3 --version)"
fi
fi
if has_language nodejs; then
if command -v node >/dev/null 2>&1; then
echo "Node.js: $(node --version)"
else
echo "Installing Node.js 22..."
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y -qq nodejs
echo "Installed Node.js: $(node --version)"
fi
fi
if has_language go; then
if command -v /usr/local/go/bin/go >/dev/null 2>&1; then
echo "Go: $(/usr/local/go/bin/go version)"
else
echo "Installing Go..."
ARCH=$(uname -m)
case $ARCH in
x86_64) GOARCH="amd64" ;;
aarch64) GOARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
GO_VERSION=$(curl -fsSL "https://go.dev/VERSION?m=text" | head -1)
curl -fsSL "https://go.dev/dl/$${GO_VERSION}.linux-$${GOARCH}.tar.gz" | sudo tar -C /usr/local -xz
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' | sudo tee /etc/profile.d/go.sh >/dev/null
echo "Installed Go: $(/usr/local/go/bin/go version)"
fi
fi
if has_language rust; then
if command -v rustc >/dev/null 2>&1 || [ -f "$HOME/.cargo/bin/rustc" ]; then
RUSTC=$${HOME}/.cargo/bin/rustc
command -v rustc >/dev/null 2>&1 && RUSTC=rustc
echo "Rust: $($RUSTC --version)"
else
echo "Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "Installed Rust: $($HOME/.cargo/bin/rustc --version)"
fi
fi
if has_language java; then
if command -v java >/dev/null 2>&1; then
echo "Java: $(java --version 2>&1 | head -1)"
else
echo "Installing Java (OpenJDK 21)..."
apt_update
sudo apt-get install -y -qq openjdk-21-jdk
echo "Installed Java: $(java --version 2>&1 | head -1)"
fi
fi
if has_language cpp; then
if command -v gcc >/dev/null 2>&1; then
echo "C/C++: $(gcc --version | head -1)"
else
echo "Installing C/C++ toolchain..."
apt_update
sudo apt-get install -y -qq gcc g++ make cmake
echo "Installed C/C++: $(gcc --version | head -1)"
fi
fi
echo "Language setup complete."