Skip to content

Commit 01a4c08

Browse files
bpmctclaude
andcommitted
feat(scripts): add --with-tasks flag to develop.sh
Add a --with-tasks flag to develop.sh that automatically sets up a tasks-compatible development environment. When enabled, it creates the tasks-docker template and pulls the required container image in the background to speed up workspace creation. The flag also sets a blank access URL to enable tunnel mode, which provides automatic subdomain support for workspace apps without requiring wildcard-access-url configuration. Updated the dogfood template to use this flag by default, making it easier to develop Coder Tasks features using Tasks itself. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 67024b8 commit 01a4c08

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

dogfood/coder/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ resource "coder_script" "develop_sh" {
924924
echo "Waiting for agent startup script to finish... ($attempt/60)"
925925
sleep 10
926926
done
927-
cd "${local.repo_dir}" && screen -dmS develop_sh /bin/sh -c 'while true; do ./scripts/develop.sh --; echo "develop.sh exited with code $? restarting in 30s"; sleep 30; done'
927+
cd "${local.repo_dir}" && screen -dmS develop_sh /bin/sh -c 'while true; do ./scripts/develop.sh --with-tasks --; echo "develop.sh exited with code $? restarting in 30s"; sleep 30; done'
928928
EOT
929929
}
930930

scripts/develop.sh

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env bash
22

3-
# Usage: ./develop.sh [--agpl]
3+
# Usage: ./develop.sh [--agpl] [--with-tasks]
44
#
55
# If the --agpl parameter is specified, builds only the AGPL-licensed code (no
66
# Coder enterprise features).
7+
#
8+
# If the --with-tasks parameter is specified, creates the tasks-docker template
9+
# and pulls the container image in the background.
710

811
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
912
# shellcheck source=scripts/lib.sh
@@ -20,13 +23,14 @@ DEFAULT_PASSWORD="SomeSecurePassword!"
2023
password="${CODER_DEV_ADMIN_PASSWORD:-${DEFAULT_PASSWORD}}"
2124
use_proxy=0
2225
multi_org=0
26+
with_tasks=0
2327

2428
# Ensure that extant environment variables do not override
2529
# the config dir we use to override auth for dev.coder.com.
2630
unset CODER_SESSION_TOKEN
2731
unset CODER_URL
2832

29-
args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization -- "$@")"
33+
args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization,with-tasks -- "$@")"
3034
eval set -- "$args"
3135
while true; do
3236
case "$1" in
@@ -50,6 +54,10 @@ while true; do
5054
multi_org=1
5155
shift
5256
;;
57+
--with-tasks)
58+
with_tasks=1
59+
shift
60+
;;
5361
--debug)
5462
debug=1
5563
shift
@@ -76,6 +84,11 @@ if [ -n "${CODER_AGENT_URL:-}" ]; then
7684
DEVELOP_IN_CODER=1
7785
fi
7886

87+
# When using --with-tasks, use blank access URL to enable tunnel mode
88+
if [ "${with_tasks}" -gt "0" ]; then
89+
CODER_DEV_ACCESS_URL=""
90+
fi
91+
7992
# Preflight checks: ensure we have our required dependencies, and make sure nothing is listening on port 3000 or 8080
8093
dependencies curl git go jq make pnpm
8194

@@ -258,6 +271,37 @@ fatal() {
258271
) || echo "Failed to create a template. The template files are in ${temp_template_dir}"
259272
fi
260273

274+
# If --with-tasks flag is set and docker is available, create the tasks-docker template
275+
if [ "${with_tasks}" -gt "0" ]; then
276+
template_name="tasks-docker"
277+
if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then
278+
echo "Initializing tasks-docker template..."
279+
280+
# Pull the container image in the background to speed up workspace creation
281+
container_image="codercom/example-universal:ubuntu"
282+
echo "Pulling container image ${container_image} in background..."
283+
docker pull "${container_image}" >/dev/null 2>&1 &
284+
285+
# Create template from the examples directory
286+
temp_template_dir="$(mktemp -d)"
287+
cp -r "${PROJECT_ROOT}/examples/templates/tasks-docker/"* "${temp_template_dir}/"
288+
289+
# Run terraform init
290+
pushd "${temp_template_dir}" && terraform init && popd
291+
292+
DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
293+
(
294+
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+
if [ "${multi_org}" -gt "0" ]; then
297+
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+
fi
300+
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
301+
) || echo "Failed to create tasks-docker template. The template files are in ${temp_template_dir}"
302+
fi
303+
fi
304+
261305
if [ "${use_proxy}" -gt "0" ]; then
262306
log "Using external workspace proxy"
263307
(

0 commit comments

Comments
 (0)