diff --git a/cli/testdata/coder_templates_init_--help.golden b/cli/testdata/coder_templates_init_--help.golden index 01bf926a9e6ea..4d3cd1c2a1228 100644 --- a/cli/testdata/coder_templates_init_--help.golden +++ b/cli/testdata/coder_templates_init_--help.golden @@ -6,7 +6,7 @@ USAGE: Get started with a templated template. OPTIONS: - --id aws-devcontainer|aws-linux|aws-windows|azure-linux|devcontainer-docker|devcontainer-kubernetes|do-linux|docker|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|nomad-docker|scratch + --id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|kubernetes|kubernetes-devcontainer|nomad-docker|scratch Specify a given example template by ID. ——— diff --git a/docs/admin/templates/extending-templates/docker-in-workspaces.md b/docs/admin/templates/extending-templates/docker-in-workspaces.md index 418264a17470f..45439830e3ef6 100644 --- a/docs/admin/templates/extending-templates/docker-in-workspaces.md +++ b/docs/admin/templates/extending-templates/docker-in-workspaces.md @@ -148,7 +148,7 @@ nodes. Refer to sysbox's to ensure your nodes are compliant. To get started with `envbox` check out the -[starter template](https://github.com/coder/coder/tree/main/examples/templates/envbox) +[starter template](https://github.com/coder/coder/tree/main/examples/templates/kubernetes-envbox) or visit the [repo](https://github.com/coder/envbox). ### Authenticating with a Private Registry diff --git a/docs/admin/templates/managing-templates/devcontainers/add-devcontainer.md b/docs/admin/templates/managing-templates/devcontainers/add-devcontainer.md index 18dabcf2b23b3..3d4a049b138e2 100644 --- a/docs/admin/templates/managing-templates/devcontainers/add-devcontainer.md +++ b/docs/admin/templates/managing-templates/devcontainers/add-devcontainer.md @@ -38,7 +38,7 @@ choose a template from the 1. Use the `template init` command to initialize your choice of image: ```shell - coder template init --id devcontainer-kubernetes + coder template init --id kubernetes-devcontainer ``` A list of available templates is shown in the @@ -47,7 +47,7 @@ choose a template from the 1. `cd` into the directory and push the template to your Coder deployment: ```shell - cd devcontainer-kubernetes && coder templates push + cd kubernetes-devcontainer && coder templates push ``` You can also edit the files or make changes to the files before you push them @@ -122,8 +122,8 @@ their development environments: | Template | Description | | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Docker dev containers](https://github.com/coder/coder/tree/main/examples/templates/devcontainer-docker) | Docker provisions a development container. | -| [Kubernetes dev containers](https://github.com/coder/coder/tree/main/examples/templates/devcontainer-kubernetes) | Provisions a development container on the Kubernetes cluster. | +| [Docker dev containers](https://github.com/coder/coder/tree/main/examples/templates/docker-devcontainer) | Docker provisions a development container. | +| [Kubernetes dev containers](https://github.com/coder/coder/tree/main/examples/templates/kubernetes-devcontainer) | Provisions a development container on the Kubernetes cluster. | | [Google Compute Engine dev container](https://github.com/coder/coder/tree/main/examples/templates/gcp-devcontainer) | Runs a development container inside a single GCP instance. It also mounts the Docker socket from the VM inside the container to enable Docker inside the workspace. | | [AWS EC2 dev container](https://github.com/coder/coder/tree/main/examples/templates/aws-devcontainer) | Runs a development container inside a single EC2 instance. It also mounts the Docker socket from the VM inside the container to enable Docker inside the workspace. | diff --git a/docs/reference/cli/templates_init.md b/docs/reference/cli/templates_init.md index ddbd84ab3d2c8..1e5da9ffbff9c 100644 --- a/docs/reference/cli/templates_init.md +++ b/docs/reference/cli/templates_init.md @@ -14,8 +14,8 @@ coder templates init [flags] [directory] ### --id -| | | -| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Type | aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|devcontainer-docker\|devcontainer-kubernetes\|do-linux\|docker\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|kubernetes\|nomad-docker\|scratch | +| | | +| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Type | aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|digitalocean-linux\|docker\|docker-devcontainer\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|kubernetes\|kubernetes-devcontainer\|nomad-docker\|scratch | Specify a given example template by ID. diff --git a/examples/examples.gen.json b/examples/examples.gen.json index 92260bb4c42b6..0f7d7f605c8fe 100644 --- a/examples/examples.gen.json +++ b/examples/examples.gen.json @@ -56,7 +56,7 @@ "markdown": "\n# Remote Development on Azure VMs (Linux)\n\nProvision Azure Linux VMs as [Coder workspaces](https://coder.com/docs/workspaces) with this example template.\n\n\u003c!-- TODO: Add screenshot --\u003e\n\n## Prerequisites\n\n### Authentication\n\nThis template assumes that coderd is run in an environment that is authenticated\nwith Azure. For example, run `az login` then `az account set --subscription=\u003cid\u003e`\nto import credentials on the system and user running coderd. For other ways to\nauthenticate, [consult the Terraform docs](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#authenticating-to-azure).\n\n## Architecture\n\nThis template provisions the following resources:\n\n- Azure VM (ephemeral, deleted on stop)\n- Managed disk (persistent, mounted to `/home/coder`)\n\nThis means, when the workspace restarts, any tools or files outside of the home directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the VM image, or use a [startup script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script). Alternatively, individual developers can [personalize](https://coder.com/docs/dotfiles) their workspaces with dotfiles.\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n## code-server\n\n`code-server` is installed via the `startup_script` argument in the `coder_agent`\nresource block. The `coder_app` resource is defined to access `code-server` through\nthe dashboard UI over `localhost:13337`.\n" }, { - "id": "do-linux", + "id": "digitalocean-linux", "url": "", "name": "DigitalOcean Droplet (Linux)", "description": "Provision DigitalOcean Droplets as Coder workspaces", @@ -81,9 +81,9 @@ "markdown": "\n# Remote Development on Docker Containers\n\nProvision Docker containers as [Coder workspaces](https://coder.com/docs/workspaces) with this example template.\n\n\u003c!-- TODO: Add screenshot --\u003e\n\n## Prerequisites\n\n### Infrastructure\n\nThe VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group:\n\n```sh\n# Add coder user to Docker group\nsudo adduser coder docker\n\n# Restart Coder server\nsudo systemctl restart coder\n\n# Test Docker\nsudo -u coder docker ps\n```\n\n## Architecture\n\nThis template provisions the following resources:\n\n- Docker image (built by Docker socket and kept locally)\n- Docker container pod (ephemeral)\n- Docker volume (persistent on `/home/coder`)\n\nThis means, when the workspace restarts, any tools or files outside of the home directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the container image. Alternatively, individual developers can [personalize](https://coder.com/docs/dotfiles) their workspaces with dotfiles.\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n### Editing the image\n\nEdit the `Dockerfile` and run `coder templates push` to update workspaces.\n" }, { - "id": "devcontainer-docker", + "id": "docker-devcontainer", "url": "", - "name": "Devcontainers (Docker)", + "name": "Docker (Devcontainer)", "description": "Provision envbuilder containers as Coder workspaces", "icon": "/icon/docker.png", "tags": [ @@ -93,19 +93,6 @@ ], "markdown": "\n# Remote Development on Docker Containers (with Devcontainers)\n\nProvision Devcontainers as [Coder workspaces](https://coder.com/docs/workspaces) in Docker with this example template.\n\n## Prerequisites\n\n### Infrastructure\n\nCoder must have access to a running Docker socket, and the `coder` user must be a member of the `docker` group:\n\n```shell\n# Add coder user to Docker group\nsudo usermod -aG docker coder\n\n# Restart Coder server\nsudo systemctl restart coder\n\n# Test Docker\nsudo -u coder docker ps\n```\n\n## Architecture\n\nCoder supports Devcontainers via [envbuilder](https://github.com/coder/envbuilder), an open source project. Read more about this in [Coder's documentation](https://coder.com/docs/templates/dev-containers).\n\nThis template provisions the following resources:\n\n- Envbuilder cached image (conditional, persistent) using [`terraform-provider-envbuilder`](https://github.com/coder/terraform-provider-envbuilder)\n- Docker image (persistent) using [`envbuilder`](https://github.com/coder/envbuilder)\n- Docker container (ephemeral)\n- Docker volume (persistent on `/workspaces`)\n\nThe Git repository is cloned inside the `/workspaces` volume if not present.\nAny local changes to the Devcontainer files inside the volume will be applied when you restart the workspace.\nKeep in mind that any tools or files outside of `/workspaces` or not added as part of the Devcontainer specification are not persisted.\nEdit the `devcontainer.json` instead!\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n## Docker-in-Docker\n\nSee the [Envbuilder documentation](https://github.com/coder/envbuilder/blob/main/docs/docker.md) for information on running Docker containers inside a devcontainer built by Envbuilder.\n\n## Caching\n\nTo speed up your builds, you can use a container registry as a cache.\nWhen creating the template, set the parameter `cache_repo` to a valid Docker repository.\n\nFor example, you can run a local registry:\n\n```shell\ndocker run --detach \\\n --volume registry-cache:/var/lib/registry \\\n --publish 5000:5000 \\\n --name registry-cache \\\n --net=host \\\n registry:2\n```\n\nThen, when creating the template, enter `localhost:5000/devcontainer-cache` for the parameter `cache_repo`.\n\nSee the [Envbuilder Terraform Provider Examples](https://github.com/coder/terraform-provider-envbuilder/blob/main/examples/resources/envbuilder_cached_image/envbuilder_cached_image_resource.tf/) for a more complete example of how the provider works.\n\n\u003e [!NOTE] We recommend using a registry cache with authentication enabled.\n\u003e To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_docker_config_path`\n\u003e with the path to a Docker config `.json` on disk containing valid credentials for the registry.\n" }, - { - "id": "devcontainer-kubernetes", - "url": "", - "name": "Devcontainers (Kubernetes)", - "description": "Provision envbuilder pods as Coder workspaces", - "icon": "/icon/k8s.png", - "tags": [ - "container", - "kubernetes", - "devcontainer" - ], - "markdown": "\n# Remote Development on Kubernetes Pods (with Devcontainers)\n\nProvision Devcontainers as [Coder workspaces](https://coder.com/docs/workspaces) on Kubernetes with this example template.\n\n## Prerequisites\n\n### Infrastructure\n\n**Cluster**: This template requires an existing Kubernetes cluster.\n\n**Container Image**: This template uses the [envbuilder image](https://github.com/coder/envbuilder) to build a Devcontainer from a `devcontainer.json`.\n\n**(Optional) Cache Registry**: Envbuilder can utilize a Docker registry as a cache to speed up workspace builds. The [envbuilder Terraform provider](https://github.com/coder/terraform-provider-envbuilder) will check the contents of the cache to determine if a prebuilt image exists. In the case of some missing layers in the registry (partial cache miss), Envbuilder can still utilize some of the build cache from the registry.\n\n### Authentication\n\nThis template authenticates using a `~/.kube/config`, if present on the server, or via built-in authentication if the Coder provisioner is running on Kubernetes with an authorized ServiceAccount. To use another [authentication method](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template.\n\n## Architecture\n\nCoder supports devcontainers with [envbuilder](https://github.com/coder/envbuilder), an open source project. Read more about this in [Coder's documentation](https://coder.com/docs/templates/dev-containers).\n\nThis template provisions the following resources:\n\n- Kubernetes deployment (ephemeral)\n- Kubernetes persistent volume claim (persistent on `/workspaces`)\n- Envbuilder cached image (optional, persistent).\n\nThis template will fetch a Git repo containing a `devcontainer.json` specified by the `repo` parameter, and builds it\nwith [`envbuilder`](https://github.com/coder/envbuilder).\nThe Git repository is cloned inside the `/workspaces` volume if not present.\nAny local changes to the Devcontainer files inside the volume will be applied when you restart the workspace.\nAs you might suspect, any tools or files outside of `/workspaces` or not added as part of the Devcontainer specification are not persisted.\nEdit the `devcontainer.json` instead!\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n## Caching\n\nTo speed up your builds, you can use a container registry as a cache.\nWhen creating the template, set the parameter `cache_repo`.\n\nSee the [Envbuilder Terraform Provider Examples](https://github.com/coder/terraform-provider-envbuilder/blob/main/examples/resources/envbuilder_cached_image/envbuilder_cached_image_resource.tf/) for a more complete example of how the provider works.\n\n\u003e [!NOTE] We recommend using a registry cache with authentication enabled.\n\u003e To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_dockerconfig_secret`\n\u003e with the name of a Kubernetes secret in the same namespace as Coder. The secret must contain the key `.dockerconfigjson`.\n" - }, { "id": "gcp-devcontainer", "url": "", @@ -171,6 +158,19 @@ ], "markdown": "\n# Remote Development on Kubernetes Pods\n\nProvision Kubernetes Pods as [Coder workspaces](https://coder.com/docs/workspaces) with this example template.\n\n\u003c!-- TODO: Add screenshot --\u003e\n\n## Prerequisites\n\n### Infrastructure\n\n**Cluster**: This template requires an existing Kubernetes cluster\n\n**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.\n\n### Authentication\n\nThis template authenticates using a `~/.kube/config`, if present on the server, or via built-in authentication if the Coder provisioner is running on Kubernetes with an authorized ServiceAccount. To use another [authentication method](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template.\n\n## Architecture\n\nThis template provisions the following resources:\n\n- Kubernetes pod (ephemeral)\n- Kubernetes persistent volume claim (persistent on `/home/coder`)\n\nThis means, when the workspace restarts, any tools or files outside of the home directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the container image. Alternatively, individual developers can [personalize](https://coder.com/docs/dotfiles) their workspaces with dotfiles.\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n" }, + { + "id": "kubernetes-devcontainer", + "url": "", + "name": "Kubernetes (Devcontainer)", + "description": "Provision envbuilder pods as Coder workspaces", + "icon": "/icon/k8s.png", + "tags": [ + "container", + "kubernetes", + "devcontainer" + ], + "markdown": "\n# Remote Development on Kubernetes Pods (with Devcontainers)\n\nProvision Devcontainers as [Coder workspaces](https://coder.com/docs/workspaces) on Kubernetes with this example template.\n\n## Prerequisites\n\n### Infrastructure\n\n**Cluster**: This template requires an existing Kubernetes cluster.\n\n**Container Image**: This template uses the [envbuilder image](https://github.com/coder/envbuilder) to build a Devcontainer from a `devcontainer.json`.\n\n**(Optional) Cache Registry**: Envbuilder can utilize a Docker registry as a cache to speed up workspace builds. The [envbuilder Terraform provider](https://github.com/coder/terraform-provider-envbuilder) will check the contents of the cache to determine if a prebuilt image exists. In the case of some missing layers in the registry (partial cache miss), Envbuilder can still utilize some of the build cache from the registry.\n\n### Authentication\n\nThis template authenticates using a `~/.kube/config`, if present on the server, or via built-in authentication if the Coder provisioner is running on Kubernetes with an authorized ServiceAccount. To use another [authentication method](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template.\n\n## Architecture\n\nCoder supports devcontainers with [envbuilder](https://github.com/coder/envbuilder), an open source project. Read more about this in [Coder's documentation](https://coder.com/docs/templates/dev-containers).\n\nThis template provisions the following resources:\n\n- Kubernetes deployment (ephemeral)\n- Kubernetes persistent volume claim (persistent on `/workspaces`)\n- Envbuilder cached image (optional, persistent).\n\nThis template will fetch a Git repo containing a `devcontainer.json` specified by the `repo` parameter, and builds it\nwith [`envbuilder`](https://github.com/coder/envbuilder).\nThe Git repository is cloned inside the `/workspaces` volume if not present.\nAny local changes to the Devcontainer files inside the volume will be applied when you restart the workspace.\nAs you might suspect, any tools or files outside of `/workspaces` or not added as part of the Devcontainer specification are not persisted.\nEdit the `devcontainer.json` instead!\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n## Caching\n\nTo speed up your builds, you can use a container registry as a cache.\nWhen creating the template, set the parameter `cache_repo`.\n\nSee the [Envbuilder Terraform Provider Examples](https://github.com/coder/terraform-provider-envbuilder/blob/main/examples/resources/envbuilder_cached_image/envbuilder_cached_image_resource.tf/) for a more complete example of how the provider works.\n\n\u003e [!NOTE] We recommend using a registry cache with authentication enabled.\n\u003e To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_dockerconfig_secret`\n\u003e with the name of a Kubernetes secret in the same namespace as Coder. The secret must contain the key `.dockerconfigjson`.\n" + }, { "id": "nomad-docker", "url": "", diff --git a/examples/examples.go b/examples/examples.go index ef3a47549528d..8cce81a5897b3 100644 --- a/examples/examples.go +++ b/examples/examples.go @@ -27,15 +27,15 @@ var ( //go:embed templates/aws-linux //go:embed templates/aws-windows //go:embed templates/azure-linux - //go:embed templates/do-linux + //go:embed templates/digitalocean-linux //go:embed templates/docker - //go:embed templates/devcontainer-docker - //go:embed templates/devcontainer-kubernetes + //go:embed templates/docker-devcontainer //go:embed templates/gcp-devcontainer //go:embed templates/gcp-linux //go:embed templates/gcp-vm-container //go:embed templates/gcp-windows //go:embed templates/kubernetes + //go:embed templates/kubernetes-devcontainer //go:embed templates/nomad-docker //go:embed templates/scratch files embed.FS diff --git a/examples/templates/do-linux/README.md b/examples/templates/digitalocean-linux/README.md similarity index 100% rename from examples/templates/do-linux/README.md rename to examples/templates/digitalocean-linux/README.md diff --git a/examples/templates/do-linux/cloud-config.yaml.tftpl b/examples/templates/digitalocean-linux/cloud-config.yaml.tftpl similarity index 100% rename from examples/templates/do-linux/cloud-config.yaml.tftpl rename to examples/templates/digitalocean-linux/cloud-config.yaml.tftpl diff --git a/examples/templates/do-linux/main.tf b/examples/templates/digitalocean-linux/main.tf similarity index 100% rename from examples/templates/do-linux/main.tf rename to examples/templates/digitalocean-linux/main.tf diff --git a/examples/templates/devcontainer-docker/README.md b/examples/templates/docker-devcontainer/README.md similarity index 98% rename from examples/templates/devcontainer-docker/README.md rename to examples/templates/docker-devcontainer/README.md index 930c9e6cceb53..7b58c5b8cde86 100644 --- a/examples/templates/devcontainer-docker/README.md +++ b/examples/templates/docker-devcontainer/README.md @@ -1,5 +1,5 @@ --- -display_name: Devcontainers (Docker) +display_name: Docker (Devcontainer) description: Provision envbuilder containers as Coder workspaces icon: ../../../site/static/icon/docker.png maintainer_github: coder diff --git a/examples/templates/devcontainer-docker/main.tf b/examples/templates/docker-devcontainer/main.tf similarity index 100% rename from examples/templates/devcontainer-docker/main.tf rename to examples/templates/docker-devcontainer/main.tf diff --git a/examples/templates/devcontainer-kubernetes/README.md b/examples/templates/kubernetes-devcontainer/README.md similarity index 98% rename from examples/templates/devcontainer-kubernetes/README.md rename to examples/templates/kubernetes-devcontainer/README.md index b66b19c01ef84..35bb6f1013d40 100644 --- a/examples/templates/devcontainer-kubernetes/README.md +++ b/examples/templates/kubernetes-devcontainer/README.md @@ -1,5 +1,5 @@ --- -display_name: Devcontainers (Kubernetes) +display_name: Kubernetes (Devcontainer) description: Provision envbuilder pods as Coder workspaces icon: ../../../site/static/icon/k8s.png maintainer_github: coder diff --git a/examples/templates/devcontainer-kubernetes/main.tf b/examples/templates/kubernetes-devcontainer/main.tf similarity index 100% rename from examples/templates/devcontainer-kubernetes/main.tf rename to examples/templates/kubernetes-devcontainer/main.tf diff --git a/examples/templates/envbox/README.md b/examples/templates/kubernetes-envbox/README.md similarity index 99% rename from examples/templates/envbox/README.md rename to examples/templates/kubernetes-envbox/README.md index 2562d55982bd3..8fcd5f8ddf449 100644 --- a/examples/templates/envbox/README.md +++ b/examples/templates/kubernetes-envbox/README.md @@ -1,5 +1,5 @@ --- -display_name: Envbox (Kubernetes) +display_name: Kubernetes (Envbox) description: Provision envbox pods as Coder workspaces icon: ../../../site/static/icon/k8s.png maintainer_github: coder diff --git a/examples/templates/envbox/main.tf b/examples/templates/kubernetes-envbox/main.tf similarity index 100% rename from examples/templates/envbox/main.tf rename to examples/templates/kubernetes-envbox/main.tf