develop.sh: attempt to create a Docker template automatically (#2627)

This commit makes the following changes:

- Adds two variables docker_host and docker_arch to the example docker-code-server template
- Adds an example params.yaml to docker-code-server and updates the README.md to reference these parameters
- scripts/develop.sh will now attempt to create a template using docker-code-server with the appropriate parameters for the environment
- Updated Lima example to make use of the template parameters for docker-code-server


Additional drive-bys:

- webpack.dev.ts references CODER_HOST and not CODERV2_HOST; updated develop.sh accordingly
- develop.sh should now terminate child processes upon error.
This commit is contained in:
Cian Johnston
2022-06-27 09:59:08 +01:00
committed by GitHub
parent f9d830a2b6
commit bbbd5241c3
6 changed files with 82 additions and 14 deletions
@@ -8,4 +8,18 @@ tags: [local, docker]
## Getting started
Run `coder templates init` and select this template. Follow the instructions that appear.
Run `coder templates init` and select this template. Follow the instructions that appear.
## Supported Parameters
You can create a file containing parameters and pass the argument
`--parameter-file` to `coder templates create`.
See `params.sample.yaml` for more information.
This template has the following predefined parameters:
- `docker_host`: Path to (or address of) the Docker socket.
> You can determine the correct value for this by runnning
> `docker context ls`.
- `docker_arch`: Architecture of the host running Docker.
This can be `amd64`, `arm64`, or `armv7`.
+19 -1
View File
@@ -11,14 +11,32 @@ terraform {
}
}
variable "docker_host" {
description = "Specify location of Docker socket (check `docker context ls` if you're not sure)"
sensitive = true
}
variable "docker_arch" {
description = "Specify architecture of docker host (amd64, arm64, or armv7)"
validation {
condition = contains(["amd64", "arm64", "armv7"], var.docker_arch)
error_message = "Value must be amd64, arm64, or armv7."
}
sensitive = true
}
provider "coder" {
}
provider "docker" {
host = var.docker_host
}
data "coder_workspace" "me" {
}
resource "coder_agent" "dev" {
arch = "amd64"
arch = var.docker_arch
os = "linux"
startup_script = "code-server --auth none"
}
@@ -0,0 +1,2 @@
docker_host: "unix:///var/run/docker.sock"
docker_arch: "amd64"