Skip to content

Conversation

@bpmct
Copy link
Member

@bpmct bpmct commented Dec 9, 2025

Remove the --with-tasks flag and always create both docker and tasks-docker templates in develop.sh. This provides a better developer experience by making the tasks-docker template available automatically without requiring a flag.

When docker is available, the script now:

  • Creates the docker template (existing behavior)
  • Creates the tasks-docker template from examples/templates/tasks-docker
  • Pulls the container image (codercom/example-universal:ubuntu) in the background to speed up workspace creation

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@bpmct bpmct marked this pull request as ready for review December 9, 2025 01:46
@bpmct bpmct requested a review from matifali December 9, 2025 01:46
@bpmct
Copy link
Member Author

bpmct commented Dec 9, 2025

I have confirmed this works!

@bpmct bpmct requested a review from geokat December 9, 2025 22:55
@bpmct bpmct force-pushed the feat/add-tasks-template-flag branch from a82d8b2 to 34d30a5 Compare December 10, 2025 15:11
@bpmct bpmct changed the title feat(scripts): add --with-tasks flag to develop.sh feat(scripts): create both docker and tasks-docker templates by default Dec 10, 2025
@bpmct bpmct requested a review from deansheather December 10, 2025 15:14
@bpmct bpmct changed the title feat(scripts): create both docker and tasks-docker templates by default feat(scripts): create both docker and tasks-docker templates by default for developer.sh Dec 10, 2025
bpmct and others added 4 commits December 10, 2025 15:16
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>
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.
Per Dean's feedback, remove the --with-tasks flag and always create
both the docker and tasks-docker templates in develop.sh. This provides
a better developer experience by making the tasks-docker template
available without requiring a flag.

Changes:
- Remove --with-tasks flag and associated argument parsing
- Always create both docker and tasks-docker templates when docker is available
- Pull container image in background for tasks-docker to speed up workspace creation
- Update dogfood template to remove --with-tasks usage (no longer needed)
The main.tf changes were unrelated to this PR. Reverting to match main
branch exactly.
@bpmct bpmct force-pushed the feat/add-tasks-template-flag branch from 4e115ea to f98cf44 Compare December 10, 2025 15:16
Addresses Dean's code review feedback:
- Remove redundant first_org_name variable in tasks-docker section (already
  defined in docker section above)
- Extract template pushing logic into a shared push_template() function to
  reduce code duplication between docker and tasks-docker template creation
…late

The tasks-docker example template doesn't need custom docker socket
configuration - it works fine with the default docker provider configuration.
Removed the docker_socket variable addition and updated push_template()
function to optionally use params.yaml only when it exists.
@bpmct bpmct requested a review from deansheather December 10, 2025 19:50
@bpmct bpmct changed the title feat(scripts): create both docker and tasks-docker templates by default for developer.sh feat(scripts): create both docker and tasks-docker templates by default for develop.sh Dec 10, 2025

DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal but the parenthesis are not required anymore.

Comment on lines +277 to +300
if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then
# sometimes terraform isn't installed yet when we go to create the
# template
echo "Waiting for terraform to be installed..."
sleep 5

echo "Initializing tasks-docker template..."

# Pull the container image in the background to speed up workspace creation
container_image="codercom/example-universal:ubuntu"
echo "Pulling container image ${container_image} in background..."
docker pull "${container_image}" >/dev/null 2>&1 &

# Create template from the examples directory
temp_template_dir="$(mktemp -d)"
cp -r "${PROJECT_ROOT}/examples/templates/tasks-docker/"* "${temp_template_dir}/"

# Run terraform init so we get a terraform.lock.hcl
pushd "${temp_template_dir}" && terraform init && popd

(
push_template "${template_name}" "${temp_template_dir}" "${first_org_name}" "${another_org}"
) || echo "Failed to create tasks-docker template. The template files are in ${temp_template_dir}"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not make the regular docker template the same as this? It's missing the terraform check, the background pulling, the terraform init. It'd be nice if these could just be identical and just be ~two lines

# sometimes terraform isn't installed yet when we go to create the
# template
echo "Waiting for terraform to be installed..."
sleep 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a (bounded) loop with command -v terraform or something to test for it being installed rather than a sleep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants