- Notifications
You must be signed in to change notification settings - Fork928
feat: set $HOME for coder agent in gcp-linux template#2147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -70,5 +70,21 @@ resource "google_compute_instance" "dev" { | ||
email = data.google_compute_default_service_account.default.email | ||
scopes = ["cloud-platform"] | ||
} | ||
# The startup script runs as root with no $HOME environment set up, which can break workspace applications, so | ||
# instead of directly running the agent init script, setup the home directory, write the init script, and then execute | ||
# it. | ||
metadata_startup_script = <<EOMETA | ||
#!/usr/bin/env sh | ||
set -eux pipefail | ||
mkdir /root || true | ||
cat <<'EOCODER' > /root/coder_agent.sh | ||
${coder_agent.dev.init_script} | ||
EOCODER | ||
chmod +x /root/coder_agent.sh | ||
export HOME=/root | ||
/root/coder_agent.sh | ||
EOMETA | ||
Comment on lines +76 to +89 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I believe you could just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I thought about that, but I want to move this template in the direction of writing scripts to disk in anticipation of further refinement where we also write a systemd unit. | ||
} |