Skip to content

Commit a121201

Browse files
authored
chore(examples): Add login_before_ready and startup_script_timeout (#5880)
1 parent 90c4d5d commit a121201

File tree

16 files changed

+126
-78
lines changed

16 files changed

+126
-78
lines changed

dogfood/main.tf

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.0"
5+
version = "0.6.10"
66
}
77
docker = {
88
source = "kreuzwerker/docker"
@@ -58,11 +58,13 @@ provider "coder" {}
5858
data "coder_workspace" "me" {}
5959

6060
resource "coder_agent" "dev" {
61-
arch = "amd64"
62-
os = "linux"
63-
startup_script = <<EOF
64-
#!/bin/sh
65-
set -x
61+
arch = "amd64"
62+
os = "linux"
63+
64+
login_before_ready = false
65+
startup_script_timeout = 60
66+
startup_script = <<-EOT
67+
set -ex
6668
# install and start code-server
6769
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
6870
code-server --auth none --port 13337 &
@@ -73,11 +75,11 @@ resource "coder_agent" "dev" {
7375
coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee -a ~/.personalize.log
7476
fi
7577
if [ -x ~/personalize ]; then
76-
~/personalize | tee -a ~/.personalize.log
78+
~/personalize 2>&1 | tee -a ~/.personalize.log
7779
elif [ -f ~/personalize ]; then
7880
echo "~/personalize is not executable, skipping..." | tee -a ~/.personalize.log
7981
fi
80-
EOF
82+
EOT
8183
}
8284

8385
resource "coder_app" "code-server" {

examples/templates/aws-ecs-container/main.tf

+13-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
}
77
coder = {
88
source = "coder/coder"
9-
version = "0.6.6"
9+
version = "0.6.10"
1010
}
1111
}
1212
}
@@ -92,15 +92,19 @@ resource "aws_ecs_service" "workspace" {
9292
data "coder_workspace" "me" {}
9393

9494
resource "coder_agent" "coder" {
95-
arch = "amd64"
96-
auth = "token"
97-
os = "linux"
98-
dir = "/home/coder"
99-
startup_script = <<EOT
100-
#!/bin/bash
95+
arch = "amd64"
96+
auth = "token"
97+
os = "linux"
98+
dir = "/home/coder"
99+
100+
login_before_ready = false
101+
startup_script_timeout = 180
102+
startup_script = <<-EOT
103+
set -e
104+
101105
# install and start code-server
102-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
103-
code-server --auth none --port 13337 | tee code-server-install.log &
106+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
107+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
104108
EOT
105109
}
106110

examples/templates/aws-linux/main.tf

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
}
88
}
@@ -73,15 +73,18 @@ data "aws_ami" "ubuntu" {
7373
}
7474

7575
resource "coder_agent" "main" {
76-
arch = "amd64"
77-
auth = "aws-instance-identity"
78-
os = "linux"
79-
startup_script = <<EOT
80-
#!/bin/bash
76+
arch = "amd64"
77+
auth = "aws-instance-identity"
78+
os = "linux"
79+
80+
login_before_ready = false
81+
startup_script_timeout = 180
82+
startup_script = <<-EOT
83+
set -e
8184
8285
# install and start code-server
83-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
84-
code-server --auth none --port 13337 | tee code-server-install.log &
86+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
87+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
8588
EOT
8689
}
8790

examples/templates/aws-windows/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
}
88
}
@@ -73,6 +73,8 @@ resource "coder_agent" "main" {
7373
arch = "amd64"
7474
auth = "aws-instance-identity"
7575
os = "windows"
76+
77+
login_before_ready = false
7678
}
7779

7880
locals {

examples/templates/azure-linux/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
azurerm = {
88
source = "hashicorp/azurerm"
@@ -83,6 +83,8 @@ resource "coder_agent" "main" {
8383
arch = "amd64"
8484
os = "linux"
8585
auth = "azure-instance-identity"
86+
87+
login_before_ready = false
8688
}
8789

8890
locals {

examples/templates/do-linux/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
digitalocean = {
88
source = "digitalocean/digitalocean"
@@ -96,6 +96,8 @@ data "coder_workspace" "me" {}
9696
resource "coder_agent" "main" {
9797
os = "linux"
9898
arch = "amd64"
99+
100+
login_before_ready = false
99101
}
100102

101103
resource "digitalocean_volume" "home_volume" {

examples/templates/docker-code-server/main.tf

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
docker = {
88
source = "kreuzwerker/docker"
@@ -21,9 +21,15 @@ data "coder_workspace" "me" {
2121
}
2222

2323
resource "coder_agent" "main" {
24-
arch = data.coder_provisioner.me.arch
25-
os = "linux"
26-
startup_script = "code-server --auth none"
24+
arch = data.coder_provisioner.me.arch
25+
os = "linux"
26+
27+
login_before_ready = false
28+
startup_script_timeout = 180
29+
startup_script = <<-EOT
30+
set -e
31+
code-server --auth none >/tmp/code-server.log 2>&1 &
32+
EOT
2733

2834
# These environment variables allow you to make Git commits right away after creating a
2935
# workspace. Note that they take precedence over configuration defined in ~/.gitconfig!

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
coder = {
55
source = "coder/coder"
6-
version = "0.6.6"
6+
version = "0.6.10"
77
}
88
docker = {
99
source = "kreuzwerker/docker"
@@ -22,14 +22,17 @@ data "coder_workspace" "me" {
2222
}
2323

2424
resource "coder_agent" "main" {
25-
arch = data.coder_provisioner.me.arch
26-
os = "linux"
27-
startup_script = <<EOT
28-
#!/bin/bash
25+
arch = data.coder_provisioner.me.arch
26+
os = "linux"
27+
28+
login_before_ready = false
29+
startup_script_timeout = 180
30+
startup_script = <<-EOT
31+
set -e
2932
3033
# install and start code-server
31-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
32-
code-server --auth none --port 13337 | tee code-server-install.log &
34+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
35+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
3336
EOT
3437
}
3538

examples/templates/docker-with-dotfiles/main.tf

+14-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99
required_providers {
1010
coder = {
1111
source = "coder/coder"
12-
version = "0.6.6"
12+
version = "0.6.10"
1313
}
1414
docker = {
1515
source = "kreuzwerker/docker"
@@ -41,9 +41,19 @@ variable "dotfiles_uri" {
4141
}
4242

4343
resource "coder_agent" "main" {
44-
arch = data.coder_provisioner.me.arch
45-
os = "linux"
46-
startup_script = var.dotfiles_uri != "" ? "coder dotfiles -y ${var.dotfiles_uri}" : null
44+
arch = data.coder_provisioner.me.arch
45+
os = "linux"
46+
47+
login_before_ready = false
48+
startup_script_timeout = 180
49+
env = { "DOTFILES_URI" = var.dotfiles_uri != "" ? var.dotfiles_uri : null }
50+
startup_script = <<-EOT
51+
set -e
52+
if [ -n "$DOTFILES_URI" ]; then
53+
echo "Installing dotfiles from $DOTFILES_URI"
54+
coder dotfiles -y "$DOTFILES_URI"
55+
fi
56+
EOT
4757
}
4858

4959
resource "docker_volume" "home_volume" {

examples/templates/docker/build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN apt-get update \
1111
&& rm -rf /var/lib/apt/lists/*
1212

1313
ARG USER=coder
14-
RUN useradd --groups sudo --no-create-home ${USER} \
14+
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
1515
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
1616
&& chmod 0440 /etc/sudoers.d/${USER}
1717
USER ${USER}

examples/templates/docker/main.tf

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
docker = {
88
source = "kreuzwerker/docker"
@@ -25,14 +25,18 @@ data "coder_workspace" "me" {
2525
}
2626

2727
resource "coder_agent" "main" {
28-
arch = data.coder_provisioner.me.arch
29-
os = "linux"
30-
startup_script = <<EOF
31-
#!/bin/sh
28+
arch = data.coder_provisioner.me.arch
29+
os = "linux"
30+
31+
login_before_ready = false
32+
startup_script_timeout = 180
33+
startup_script = <<-EOT
34+
set -e
35+
3236
# install and start code-server
3337
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
34-
code-server --auth none --port 13337
35-
EOF
38+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
39+
EOT
3640

3741
# These environment variables allow you to make Git commits right away after creating a
3842
# workspace. Note that they take precedence over configuration defined in ~/.gitconfig!

examples/templates/gcp-linux/main.tf

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
google = {
88
source = "hashicorp/google"
@@ -46,15 +46,18 @@ resource "google_compute_disk" "root" {
4646
}
4747

4848
resource "coder_agent" "main" {
49-
auth = "google-instance-identity"
50-
arch = "amd64"
51-
os = "linux"
52-
startup_script = <<EOT
53-
#!/bin/bash
49+
auth = "google-instance-identity"
50+
arch = "amd64"
51+
os = "linux"
52+
53+
login_before_ready = false
54+
startup_script_timeout = 180
55+
startup_script = <<-EOT
56+
set -e
5457
5558
# install and start code-server
56-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
57-
code-server --auth none --port 13337 | tee code-server-install.log &
59+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
60+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
5861
EOT
5962
}
6063

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

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
google = {
88
source = "hashicorp/google"
@@ -36,15 +36,18 @@ data "coder_workspace" "me" {
3636
}
3737

3838
resource "coder_agent" "main" {
39-
auth = "google-instance-identity"
40-
arch = "amd64"
41-
os = "linux"
42-
startup_script = <<EOT
43-
#!/bin/bash
39+
auth = "google-instance-identity"
40+
arch = "amd64"
41+
os = "linux"
42+
43+
login_before_ready = false
44+
startup_script_timeout = 180
45+
startup_script = <<-EOT
46+
set -e
4447
4548
# install and start code-server
46-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3 | tee code-server-install.log
47-
code-server --auth none --port 13337 | tee code-server-install.log &
49+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 4.8.3
50+
code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
4851
EOT
4952
}
5053

examples/templates/gcp-windows/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.6"
5+
version = "0.6.10"
66
}
77
google = {
88
source = "hashicorp/google"
@@ -49,6 +49,8 @@ resource "coder_agent" "main" {
4949
auth = "google-instance-identity"
5050
arch = "amd64"
5151
os = "windows"
52+
53+
login_before_ready = false
5254
}
5355

5456
resource "google_compute_instance" "dev" {

0 commit comments

Comments
 (0)