We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent9f974c8 commit8ee0787Copy full SHA for 8ee0787
examples/templates/gcp-linux/main.tf
@@ -70,5 +70,21 @@ resource "google_compute_instance" "dev" {
70
email=data.google_compute_default_service_account.default.email
71
scopes=["cloud-platform"]
72
}
73
-metadata_startup_script=coder_agent.dev.init_script
+# 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
90