Files
coder/README.md
T

64 lines
2.8 KiB
Markdown

# Coder Templates
Docker-based [Coder](https://coder.com/docs) workspace templates for the homelab, organized by development stack. Every template shares the same infrastructure and differs only in the toolchain baked into its image.
## Templates
| Template | Stack |
| --- | --- |
| [dev-web](dev-web) | Node.js, Bun, Python, Claude Code |
| [dev-backend](dev-backend) | Go, Node.js, Bun, Opencode, Claude Code |
| [dev-rust](dev-rust) | Rust, Python, Claude Code |
| [dev-c](dev-c) | C, C++, Claude Code |
| [dev-java](dev-java) | Java, Maven, SDKMAN!, Claude Code |
| [dev-robots](dev-robots) | ROS 2, Python, C++, Claude Code |
## Shared features
- **Selectable GPU support**: a `GPU Assignment` parameter attaches GPU 0, GPU 1, or both. GPU 0 is the default because GPU 1 is shared with the Ollama and Immich stacks.
- **Docker-out-of-Docker**: the host's `/var/run/docker.sock` is mounted, so workspaces can build and run containers.
- **Ollama integration**: `OLLAMA_HOST` points at `http://host.docker.internal:11434`.
- **Persistent home**: `/home/coder` is mapped to a host directory and survives restarts.
- **Telemetry**: CPU, RAM, disk, load average, swap, and GPU utilization in the Coder UI.
- **IDE support**: code-server and JetBrains Toolbox.
- **Gitea CLI**: `tea` is preinstalled for working with `git.sirblob.co` from the workspace.
- **Patched on start**: the agent runs `apt-get update` and `apt-get upgrade` each time a workspace starts.
## Layout
Each template directory is self-contained and can be pushed to Coder on its own:
```
dev-<stack>/
main.tf Providers, data sources, and shared locals
parameters.tf Workspace parameters
agent.tf Coder agent, startup script, and metadata
apps.tf code-server and JetBrains modules
container.tf Docker image build and container resource
Dockerfile Workspace image
README.md Template documentation
```
## Pushing a template
```sh
coder templates push dev-web -d ./dev-web
```
## Prerequisites
The host needs the NVIDIA container toolkit for GPU passthrough. Coder itself runs as a container and creates workspaces through the host's Docker socket, so its service needs the socket mounted and the host `docker` group added:
```yaml
volumes:
- /var/run/docker.sock:/var/run/docker.sock
group_add:
- "987"
```
Workspaces get the same GID through the `docker_group_id` template variable, which defaults to `987`. Confirm the host GID with `getent group docker` and override the variable if it differs.
## Adding tools to a template
The container's root filesystem is ephemeral and `/home/coder` is a mounted volume, so anything installed into the home directory at build time is shadowed at runtime. Install tools under `/opt` or `/usr/local` and add them to `PATH` at the end of the Dockerfile.