Skip to content

Commit 8a60ee0

Browse files
authored
add: code-server to template examples (#3739)
* add: code-server to template examples * add: code-server to gcp templates * add: code-server to gcp-linux template * update: READMEs * update: boot disk version * update: google provider version
1 parent 20086c1 commit 8a60ee0

File tree

9 files changed

+93
-3
lines changed

9 files changed

+93
-3
lines changed

examples/templates/aws-linux/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ instances provisioned by Coder:
6868
]
6969
}
7070
```
71+
72+
## code-server
73+
74+
`code-server` is installed via the `startup_script` argument in the `coder_agent`
75+
resource block. The `coder_app` resource is defined to access `code-server` through
76+
the dashboard UI over `localhost:13337`.

examples/templates/aws-linux/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ resource "coder_agent" "main" {
7676
arch = "amd64"
7777
auth = "aws-instance-identity"
7878
os = "linux"
79+
startup_script = <<EOT
80+
#!/bin/bash
81+
82+
# install and start code-server
83+
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
84+
code-server --auth none --port 13337 | tee code-server-install.log &
85+
EOT
86+
}
87+
88+
resource "coder_app" "code-server" {
89+
agent_id = coder_agent.main.id
90+
name = "code-server"
91+
url = "http://localhost:13337/?folder=/home/coder"
92+
icon = "/icon/code.svg"
7993
}
8094

8195
locals {

examples/templates/docker-image-builds/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ coder ls
146146
coder update [workspace name]
147147
```
148148

149+
## code-server
150+
151+
`code-server` is installed via the `startup_script` argument in the `coder_agent`
152+
resource block. The `coder_app` resource is defined to access `code-server` through
153+
the dashboard UI over `localhost:13337`.
154+
149155
## Extending this template
150156

151157
See the [kreuzwerker/docker](https://registry.terraform.io/providers/kreuzwerker/docker) Terraform provider documentation to

examples/templates/docker-image-builds/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ data "coder_workspace" "me" {
2424
resource "coder_agent" "main" {
2525
arch = data.coder_provisioner.me.arch
2626
os = "linux"
27+
startup_script = <<EOT
28+
#!/bin/bash
29+
30+
# install and start code-server
31+
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
32+
code-server --auth none --port 13337 | tee code-server-install.log &
33+
EOT
34+
}
35+
36+
resource "coder_app" "code-server" {
37+
agent_id = coder_agent.main.id
38+
name = "code-server"
39+
url = "http://localhost:13337/?folder=/home/coder"
40+
icon = "/icon/code.svg"
2741
}
2842

2943
variable "docker_image" {

examples/templates/docker/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ coder template push docker
4343
You can also remove images from the validation list. Workspaces using older template versions will continue using
4444
the removed image until you update the workspace to the latest version.
4545

46+
## code-server
47+
48+
`code-server` is installed via the `startup_script` argument in the `coder_agent`
49+
resource block. The `coder_app` resource is defined to access `code-server` through
50+
the dashboard UI over `localhost:13337`.
51+
4652
## Updating images
4753

4854
To reduce drift, we recommend versioning images in your registry by creating tags. To update the image tag in the template:

examples/templates/gcp-linux/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ a service account:
4343

4444
1. Generate a **JSON private key**, which will be what you provide to Coder
4545
during the setup process.
46+
47+
## code-server
48+
49+
`code-server` is installed via the `startup_script` argument in the `coder_agent`
50+
resource block. The `coder_app` resource is defined to access `code-server` through
51+
the dashboard UI over `localhost:13337`.

examples/templates/gcp-linux/main.tf

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,25 @@ resource "google_compute_disk" "root" {
4646
}
4747

4848
resource "coder_agent" "main" {
49-
auth = "google-instance-identity"
50-
arch = "amd64"
51-
os = "linux"
49+
auth = "google-instance-identity"
50+
arch = "amd64"
51+
os = "linux"
52+
startup_script = <<EOT
53+
#!/bin/bash
54+
55+
# install and start code-server
56+
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
57+
code-server --auth none --port 13337 | tee code-server-install.log &
58+
EOT
59+
}
60+
61+
# code-server
62+
resource "coder_app" "code-server" {
63+
agent_id = coder_agent.main.id
64+
name = "code-server"
65+
icon = "/icon/code.svg"
66+
url = "http://localhost:13337?folder=/home/coder"
67+
relative_path = true
5268
}
5369

5470
resource "google_compute_instance" "dev" {

examples/templates/gcp-vm-container/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ a service account:
4343

4444
1. Generate a **JSON private key**, which will be what you provide to Coder
4545
during the setup process.
46+
47+
## code-server
48+
49+
`code-server` is installed via the `startup_script` argument in the `coder_agent`
50+
resource block. The `coder_app` resource is defined to access `code-server` through
51+
the dashboard UI over `localhost:13337`.

examples/templates/gcp-vm-container/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ resource "coder_agent" "main" {
3939
auth = "google-instance-identity"
4040
arch = "amd64"
4141
os = "linux"
42+
startup_script = <<EOT
43+
#!/bin/bash
44+
45+
# install and start code-server
46+
curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
47+
code-server --auth none --port 13337 | tee code-server-install.log &
48+
EOT
49+
}
50+
51+
# code-server
52+
resource "coder_app" "code-server" {
53+
agent_id = coder_agent.main.id
54+
name = "code-server"
55+
icon = "/icon/code.svg"
56+
url = "http://localhost:13337?folder=/home/coder"
57+
relative_path = true
4258
}
4359

4460
module "gce-container" {

0 commit comments

Comments
 (0)