Skip to content

Commit a86c957

Browse files
authored
feat: set /Users/spike for coder agent in gcp-linux template (#2147)
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 3bc122b commit a86c957

File tree

1 file changed

+17
-1
lines changed
  • examples/templates/gcp-linux

1 file changed

+17
-1
lines changed

examples/templates/gcp-linux/main.tf

+17-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,21 @@ resource "google_compute_instance" "dev" {
7070
email = data.google_compute_default_service_account.default.email
7171
scopes = ["cloud-platform"]
7272
}
73-
metadata_startup_script = coder_agent.dev.init_script
73+
# The startup script runs as root with no $HOME environment set up, which can break workspace applications, so
74+
# instead of directly running the agent init script, setup the home directory, write the init script, and then execute
75+
# it.
76+
metadata_startup_script = <<EOMETA
77+
#!/usr/bin/env sh
78+
set -eux pipefail
79+
80+
mkdir /root || true
81+
cat <<'EOCODER' > /root/coder_agent.sh
82+
${coder_agent.dev.init_script}
83+
EOCODER
84+
chmod +x /root/coder_agent.sh
85+
86+
export HOME=/root
87+
/root/coder_agent.sh
88+
89+
EOMETA
7490
}

0 commit comments

Comments
 (0)