Skip to content

Commit c5f9e30

Browse files
committed
fix(scripts): pass docker_socket variable to tasks-docker template
The DOCKER_HOST variable was being set but not passed to the template. This commit: - Creates params.yaml with docker_socket parameter - Passes params.yaml via --variables-file flag to both template pushes - Adds docker_socket variable to tasks-docker template matching docker template pattern This ensures the template can connect to non-default Docker sockets when needed.
1 parent 01a4c08 commit c5f9e30

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

examples/templates/tasks-docker/main.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ terraform {
1010
}
1111
}
1212

13+
variable "docker_socket" {
14+
default = ""
15+
description = "(Optional) Docker socket URI"
16+
type = string
17+
}
18+
1319
# This template requires a valid Docker socket
1420
# However, you can reference our Kubernetes/VM
1521
# example templates and adapt the Claude Code module
1622
#
1723
# See: https://registry.coder.com/templates
18-
provider "docker" {}
24+
provider "docker" {
25+
# Defaulting to null if the variable is an empty string lets us have an optional variable without having to set our own default
26+
host = var.docker_socket != "" ? var.docker_socket : null
27+
}
1928

2029
# A `coder_ai_task` resource enables Tasks and associates
2130
# the task with the coder_app that will act as an AI agent.

scripts/develop.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,13 @@ fatal() {
290290
pushd "${temp_template_dir}" && terraform init && popd
291291

292292
DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
293+
printf 'docker_socket: "%s"\n' "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
293294
(
294295
echo "Pushing tasks-docker template to '${first_org_name}'..."
295-
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --yes --org "${first_org_name}"
296+
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}"
296297
if [ "${multi_org}" -gt "0" ]; then
297298
echo "Pushing tasks-docker template to '${another_org}'..."
298-
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --yes --org "${another_org}"
299+
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}"
299300
fi
300301
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
301302
) || echo "Failed to create tasks-docker template. The template files are in ${temp_template_dir}"

0 commit comments

Comments
 (0)