mirror of https://github.com/coder/coder.git
fix: update reference to agent.dev in examples and docs (#3198)
* fix: update agent ID in example templates * fix: update agent ID in dogfood template * chore: update default agent ID in documentation * fix: develop.sh: start FE after template is created; leave template dir around if template creation fails
This commit is contained in:
parent
9a9912c8ce
commit
2c0d57e8c0
|
@ -17,7 +17,7 @@ be used as a Coder application. For example:
|
|||
```hcl
|
||||
# Give template users the portainer.io web UI
|
||||
resource "coder_app" "portainer" {
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
name = "portainer"
|
||||
icon = "https://simpleicons.org/icons/portainer.svg"
|
||||
url = "http://localhost:8000"
|
||||
|
@ -69,7 +69,7 @@ You'll also need to specify a `coder_app` resource related to the agent. This is
|
|||
|
||||
```hcl
|
||||
resource "coder_app" "code-server" {
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
name = "code-server"
|
||||
url = "http://localhost:13337/?folder=/home/coder"
|
||||
icon = "/icon/code.svg"
|
||||
|
|
|
@ -38,7 +38,7 @@ resource "coder_agent" "main" {
|
|||
}
|
||||
|
||||
resource "coder_app" "code-server" {
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
name = "code-server"
|
||||
url = "http://localhost:13337/?folder=/home/coder"
|
||||
icon = "/icon/code.svg"
|
||||
|
|
|
@ -109,7 +109,7 @@ Content-Transfer-Encoding: 7bit
|
|||
Content-Disposition: attachment; filename="userdata.txt"
|
||||
|
||||
#!/bin/bash
|
||||
sudo -u ${local.linux_user} sh -c '${coder_agent.dev.init_script}'
|
||||
sudo -u ${local.linux_user} sh -c '${coder_agent.main.init_script}'
|
||||
--//--
|
||||
EOT
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ locals {
|
|||
user_data_start = <<EOT
|
||||
<powershell>
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
${coder_agent.dev.init_script}
|
||||
${coder_agent.main.init_script}
|
||||
</powershell>
|
||||
<persist>true</persist>
|
||||
EOT
|
||||
|
|
|
@ -15,7 +15,7 @@ terraform {
|
|||
data "coder_workspace" "me" {
|
||||
}
|
||||
|
||||
resource "coder_agent" "dev1" {
|
||||
resource "coder_agent" "main" {
|
||||
os = "linux"
|
||||
arch = "amd64"
|
||||
auth = "token"
|
||||
|
@ -32,8 +32,8 @@ resource "null_resource" "fake-compute" {
|
|||
# Run the Coder agent init script on resources
|
||||
# to access web apps and SSH:
|
||||
#
|
||||
# export CODER_AGENT_TOKEN=${coder_agent.dev1.token}
|
||||
# ${coder_agent.dev1.init_script}
|
||||
# export CODER_AGENT_TOKEN=${coder_agent.main.token}
|
||||
# ${coder_agent.main.init_script}
|
||||
}
|
||||
|
||||
resource "null_resource" "fake-disk" {
|
||||
|
|
|
@ -116,8 +116,8 @@ resource "digitalocean_droplet" "workspace" {
|
|||
user_data = templatefile("cloud-config.yaml.tftpl", {
|
||||
username = data.coder_workspace.me.owner
|
||||
home_volume_label = digitalocean_volume.home_volume.initial_filesystem_label
|
||||
init_script = base64encode(coder_agent.dev.init_script)
|
||||
coder_agent_token = coder_agent.dev.token
|
||||
init_script = base64encode(coder_agent.main.init_script)
|
||||
coder_agent_token = coder_agent.main.token
|
||||
})
|
||||
# Required to provision Fedora.
|
||||
ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : []
|
||||
|
|
|
@ -53,7 +53,7 @@ resource "coder_agent" "main" {
|
|||
}
|
||||
|
||||
resource "coder_app" "code-server" {
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
url = "http://localhost:8080/?folder=/home/coder"
|
||||
icon = "/icon/code.svg"
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ resource "docker_container" "workspace" {
|
|||
hostname = lower(data.coder_workspace.me.name)
|
||||
dns = ["1.1.1.1"]
|
||||
# Use the docker gateway if the access URL is 127.0.0.1
|
||||
entrypoint = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
|
||||
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
|
||||
host {
|
||||
host = "host.docker.internal"
|
||||
ip = "host-gateway"
|
||||
|
|
|
@ -108,8 +108,8 @@ resource "docker_container" "workspace" {
|
|||
hostname = lower(data.coder_workspace.me.name)
|
||||
dns = ["1.1.1.1"]
|
||||
# Use the docker gateway if the access URL is 127.0.0.1
|
||||
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
|
||||
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
|
||||
host {
|
||||
host = "host.docker.internal"
|
||||
ip = "host-gateway"
|
||||
|
|
|
@ -54,8 +54,8 @@ resource "docker_container" "workspace" {
|
|||
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
|
||||
dns = ["1.1.1.1"]
|
||||
# Refer to Docker host when Coder is on localhost
|
||||
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
|
||||
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
|
||||
host {
|
||||
host = "host.docker.internal"
|
||||
ip = "host-gateway"
|
||||
|
|
|
@ -88,7 +88,7 @@ resource "coder_agent" "main" {
|
|||
}
|
||||
|
||||
resource "coder_app" "code-server" {
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
name = "code-server"
|
||||
url = "http://localhost:13337/?folder=/home/coder"
|
||||
icon = "/icon/code.svg"
|
||||
|
@ -124,10 +124,10 @@ resource "docker_container" "workspace" {
|
|||
"sh", "-c",
|
||||
<<EOT
|
||||
trap '[ $? -ne 0 ] && echo === Agent script exited with non-zero code. Sleeping infinitely to preserve logs... && sleep infinity' EXIT
|
||||
${replace(coder_agent.dev.init_script, "localhost", "host.docker.internal")}
|
||||
${replace(coder_agent.main.init_script, "localhost", "host.docker.internal")}
|
||||
EOT
|
||||
]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
|
||||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
|
||||
host {
|
||||
host = "host.docker.internal"
|
||||
ip = "host-gateway"
|
||||
|
|
|
@ -79,7 +79,7 @@ set -eux pipefail
|
|||
|
||||
mkdir /root || true
|
||||
cat <<'EOCODER' > /root/coder_agent.sh
|
||||
${coder_agent.dev.init_script}
|
||||
${coder_agent.main.init_script}
|
||||
EOCODER
|
||||
chmod +x /root/coder_agent.sh
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ module "gce-container" {
|
|||
container = {
|
||||
image = "mcr.microsoft.com/vscode/devcontainers/go:1"
|
||||
command = ["sh"]
|
||||
args = ["-c", coder_agent.dev.init_script]
|
||||
args = ["-c", coder_agent.main.init_script]
|
||||
securityContext = {
|
||||
privileged : true
|
||||
}
|
||||
|
@ -85,6 +85,6 @@ resource "google_compute_instance" "dev" {
|
|||
|
||||
resource "coder_agent_instance" "dev" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
agent_id = coder_agent.dev.id
|
||||
agent_id = coder_agent.main.id
|
||||
instance_id = google_compute_instance.dev[0].instance_id
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ resource "google_compute_instance" "dev" {
|
|||
scopes = ["cloud-platform"]
|
||||
}
|
||||
metadata = {
|
||||
windows-startup-script-ps1 = coder_agent.dev.init_script
|
||||
windows-startup-script-ps1 = coder_agent.main.init_script
|
||||
serial-port-enable = "TRUE"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
|
|||
# rather than leaving things in an inconsistent state.
|
||||
trap 'kill -TERM -$$' ERR
|
||||
cdroot
|
||||
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
|
||||
"${CODER_DEV_SHIM}" server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ &
|
||||
|
||||
echo '== Waiting for Coder to become ready'
|
||||
|
@ -68,10 +67,14 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
|
|||
DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}')
|
||||
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" | tee "${temp_template_dir}/params.yaml"
|
||||
template_name="docker-${GOARCH}"
|
||||
"${CODER_DEV_SHIM}" templates create "${template_name}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes
|
||||
rm -rfv "${temp_template_dir}"
|
||||
(
|
||||
"${CODER_DEV_SHIM}" templates create "${template_name}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes &&
|
||||
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
|
||||
) || echo "Failed to create a template. The template files are in ${temp_template_dir}"
|
||||
fi
|
||||
|
||||
# Start the frontend once we have a template up and running
|
||||
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
|
||||
log
|
||||
log "======================================================================="
|
||||
log "== =="
|
||||
|
|
Loading…
Reference in New Issue