Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions registry/coder/templates/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ Provision Docker containers as [Coder workspaces](https://coder.com/docs/workspa

## Prerequisites

### Workspace image

This template exposes an `image` variable that controls which container image workspaces run. The image determines what tools, languages, and runtimes are available in the workspace out of the box, so it has a major impact on the developer experience.

Some options to consider:

| Image | Tradeoffs |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| [`codercom/example-base:ubuntu`](https://github.com/coder/images/tree/main/images/base) (default) | Minimal and lightweight, but may not include many tools developers expect by default |
| [`codercom/example-universal:ubuntu`](https://github.com/coder/images/tree/main/images/universal) | Catch-all image with many languages and tools available, but larger and slower to pull |

More language-specific images (Go, Java, Node.js, and more) are available in [coder/images](https://github.com/coder/images), and the [devcontainers/images](https://github.com/devcontainers/images) collection is another good source of ready-made development images. You can also build your own image to pre-bake the exact tools your team needs. See [Coder's image management docs](https://coder.com/docs/admin/templates/managing-templates/image-management) for additional guidance.

### Infrastructure

#### Running Coder inside Docker
Expand Down
12 changes: 11 additions & 1 deletion registry/coder/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ variable "docker_socket" {
type = string
}

variable "image" {
description = <<-EOF
Container image for workspaces. The image determines which tools and
languages are available in the workspace by default. See the template
README for guidance on choosing an image.
EOF
type = string
default = "codercom/example-base:ubuntu"
}

provider "docker" {
# Defaulting to null if the variable is an empty string lets us have an optional variable without having to set our own default
host = var.docker_socket != "" ? var.docker_socket : null
Expand Down Expand Up @@ -173,7 +183,7 @@ resource "docker_volume" "home_volume" {

resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
image = "codercom/enterprise-base:ubuntu"
image = var.image
# Uses lower() to avoid Docker restriction on container names.
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
# Hostname makes the shell more user friendly: coder@my-workspace:~$
Expand Down
13 changes: 12 additions & 1 deletion registry/coder/templates/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ Provision Kubernetes Pods as [Coder workspaces](https://coder.com/docs/workspace

**Cluster**: This template requires an existing Kubernetes cluster

**Container Image**: This template uses the [codercom/enterprise-base:ubuntu image](https://github.com/coder/enterprise-images/tree/main/images/base) with some dev tools preinstalled. To add additional tools, extend this image or build it yourself.
### Workspace image

This template exposes an `image` variable that controls which container image workspaces run. The image determines what tools, languages, and runtimes are available in the workspace out of the box, so it has a major impact on the developer experience.

Some options to consider:

| Image | Tradeoffs |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| [`codercom/example-base:ubuntu`](https://github.com/coder/images/tree/main/images/base) (default) | Minimal and lightweight, but may not include many tools developers expect by default |
| [`codercom/example-universal:ubuntu`](https://github.com/coder/images/tree/main/images/universal) | Catch-all image with many languages and tools available, but larger and slower to pull |

More language-specific images (Go, Java, Node.js, and more) are available in [coder/images](https://github.com/coder/images), and the [devcontainers/images](https://github.com/devcontainers/images) collection is another good source of ready-made development images. You can also build your own image to pre-bake the exact tools your team needs. See [Coder's image management docs](https://coder.com/docs/admin/templates/managing-templates/image-management) for additional guidance.

### Authentication

Expand Down
12 changes: 11 additions & 1 deletion registry/coder/templates/kubernetes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ variable "namespace" {
description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces). If the Coder host is itself running as a Pod on the same Kubernetes cluster as you are deploying workspaces to, set this to the same namespace."
}

variable "image" {
description = <<-EOF
Container image for workspaces. The image determines which tools and
languages are available in the workspace by default. See the template
README for guidance on choosing an image.
EOF
type = string
default = "codercom/example-base:ubuntu"
}

data "coder_parameter" "cpu" {
name = "cpu"
display_name = "CPU"
Expand Down Expand Up @@ -286,7 +296,7 @@ resource "kubernetes_deployment_v1" "main" {

container {
name = "dev"
image = "codercom/enterprise-base:ubuntu"
image = var.image
image_pull_policy = "IfNotPresent"
command = ["sh", "-c", coder_agent.main.init_script]
security_context {
Expand Down
Loading