Organize templates into per-stack folders
This commit is contained in:
@@ -1,69 +1,63 @@
|
||||
---
|
||||
display_name: Docker Workspaces with GPU & DooD
|
||||
description: Provision Docker-based Coder workspaces with selectable GPU support, Docker-out-of-Docker, Go, Bun, and Opencode.
|
||||
icon: /icon/docker.svg
|
||||
maintainer_github: sirblob
|
||||
verified: false
|
||||
tags: [docker, container, gpu, golang, bun, sdkman, opencode, ollama]
|
||||
---
|
||||
# Coder Templates
|
||||
|
||||
# Feature-Rich Docker Workspaces
|
||||
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.
|
||||
|
||||
Provision powerful Docker containers as [Coder workspaces](https://coder.com/docs/workspaces) with this template. It features selectable GPU passthrough, Docker-out-of-Docker (DooD), and pre-installs essential development tools via a custom Dockerfile.
|
||||
## 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
|
||||
|
||||
### Infrastructure
|
||||
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:
|
||||
|
||||
The host you run Coder on must have a running Docker socket, the NVIDIA container runtime installed, and the `coder` user added to the Docker group:
|
||||
|
||||
```sh
|
||||
sudo adduser coder docker
|
||||
sudo systemctl restart coder
|
||||
sudo -u coder docker ps
|
||||
```yaml
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
group_add:
|
||||
- "987"
|
||||
```
|
||||
|
||||
## Features & Architecture
|
||||
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.
|
||||
|
||||
This template provisions the following resources and features:
|
||||
## Adding tools to a template
|
||||
|
||||
- **Base Image**: Custom image built from `codercom/enterprise-base:ubuntu`.
|
||||
- **Selectable GPU Support**: A `GPU Assignment` parameter chooses which GPU(s) to attach. The default is **GPU 0**, because GPU 1 is shared with the `ollama` and `immich` stacks; pick `GPU 1 only` or `Both GPUs` when you need them.
|
||||
- **Docker-out-of-Docker (DooD)**: Mounts the host's `/var/run/docker.sock` so you can build and run containers from inside your workspace.
|
||||
- **Ollama Integration**: `OLLAMA_HOST` is preset to `http://host.docker.internal:11434`, so tools in the workspace talk to the homelab Ollama service out of the box.
|
||||
- **Pre-baked Tools**: The custom Docker image comes pre-installed with:
|
||||
- System package updates
|
||||
- Docker CLI
|
||||
- Bun
|
||||
- Go (pinned version, installed from the official tarball)
|
||||
- SDKMAN! & Maven
|
||||
- Opencode
|
||||
- `jq`, `build-essential`
|
||||
- **Persistent Storage**: Uses a persistent host directory mapped to `/home/coder` so files survive workspace restarts.
|
||||
- **Rich Telemetry**: Displays CPU, RAM, Disk, Load Average, and GPU utilization directly in the Coder UI.
|
||||
- **IDE Support**: Native integration with code-server (Browser VS Code) and JetBrains IDEs.
|
||||
|
||||
## Using the homelab services
|
||||
|
||||
### Ollama
|
||||
|
||||
`OLLAMA_HOST` is already exported in the workspace. Verify with:
|
||||
|
||||
```sh
|
||||
curl "$OLLAMA_HOST/api/tags"
|
||||
```
|
||||
|
||||
### Gitea container registry
|
||||
|
||||
With DooD enabled you can build and push images straight to the Gitea registry from inside a workspace:
|
||||
|
||||
```sh
|
||||
docker login git.sirblob.co -u <user> -p <token>
|
||||
docker build -t git.sirblob.co/<user>/<image>:<tag> .
|
||||
docker push git.sirblob.co/<user>/<image>:<tag>
|
||||
```
|
||||
|
||||
See `projects.md` in the homelab repo for the full registry workflow.
|
||||
|
||||
> **Note**
|
||||
> While your `/home/coder` directory is persistent, the container's root filesystem is ephemeral. This template builds a custom Docker image to pre-bake tools (Go, Bun, SDKMAN!, Opencode, etc.), ensuring your workspace starts instantly while keeping the tools available.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user