Skip to content

Commit c553829

Browse files
authored
chore: document startup_script and agent log location (coder#3319)
1 parent 52041be commit c553829

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/templates.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,45 @@ The `coder_agent` resource can be configured as described in the
9595
For example, you can use the `env` property to set environment variables that will be
9696
inherited by all child processes of the agent, including SSH sessions.
9797

98+
#### startup_script
99+
100+
Use the Coder agent's `startup_script` to run additional commands like
101+
installing IDEs and clone dotfile and project repos. In this example, the
102+
project and dotfile repos are specified as Terraform input variables elsewhere
103+
in the `main.tf` Note the `&` after the `code-server` start to execute
104+
`code-server` process in the background so the `startup_script` can continue
105+
with the repo cloning steps.
106+
107+
```hcl
108+
resource "coder_agent" "coder" {
109+
os = "linux"
110+
arch = "amd64"
111+
dir = "/home/coder"
112+
startup_script = <<EOT
113+
#!/bin/bash
114+
115+
# install code-server
116+
curl -fsSL https://code-server.dev/install.sh | sh
117+
code-server --auth none --port &
118+
119+
# clone repo
120+
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
121+
git clone --progress git@github.com:${var.repo}
122+
123+
# use coder CLI to clone and install dotfiles
124+
coder dotfiles -y ${var.dotfiles_uri}
125+
126+
EOT
127+
}
128+
```
129+
130+
#### Logging
131+
132+
The output of the `startup_script` are located in
133+
`/tmp/coder-startup-script.log` within the workspace.
134+
135+
The Coder agent log is located in `/tmp/coder-agent.log` within the workspace.
136+
98137
### Parameters
99138

100139
Templates often contain _parameters_. These are defined by `variable` blocks in

0 commit comments

Comments
 (0)