Skip to content

Commit a82d8b2

Browse files
committed
feat: make tasks-docker template creation the default in develop.sh
Per Dean's feedback, remove the --with-tasks flag and make tasks-docker template creation the default behavior. The tasks-docker template provides a better developer experience than the basic docker template. Changes: - Remove --with-tasks flag and associated argument parsing - Replace docker template creation with tasks-docker template - Update dogfood template to remove --with-tasks usage - Pull container image in background to speed up workspace creation
1 parent 9bf7980 commit a82d8b2

File tree

2 files changed

+19
-56
lines changed

2 files changed

+19
-56
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 --with-tasks --; 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; echo "develop.sh exited with code $? restarting in 30s"; sleep 30; done'
928928
EOT
929929
}
930930

scripts/develop.sh

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

3-
# Usage: ./develop.sh [--agpl] [--with-tasks]
3+
# Usage: ./develop.sh [--agpl]
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.
107

118
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
129
# shellcheck source=scripts/lib.sh
@@ -23,14 +20,13 @@ DEFAULT_PASSWORD="SomeSecurePassword!"
2320
password="${CODER_DEV_ADMIN_PASSWORD:-${DEFAULT_PASSWORD}}"
2421
use_proxy=0
2522
multi_org=0
26-
with_tasks=0
2723

2824
# Ensure that extant environment variables do not override
2925
# the config dir we use to override auth for dev.coder.com.
3026
unset CODER_SESSION_TOKEN
3127
unset CODER_URL
3228

33-
args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization,with-tasks -- "$@")"
29+
args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization -- "$@")"
3430
eval set -- "$args"
3531
while true; do
3632
case "$1" in
@@ -54,10 +50,6 @@ while true; do
5450
multi_org=1
5551
shift
5652
;;
57-
--with-tasks)
58-
with_tasks=1
59-
shift
60-
;;
6153
--debug)
6254
debug=1
6355
shift
@@ -84,11 +76,6 @@ if [ -n "${CODER_AGENT_URL:-}" ]; then
8476
DEVELOP_IN_CODER=1
8577
fi
8678

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-
9279
# Preflight checks: ensure we have our required dependencies, and make sure nothing is listening on port 3000 or 8080
9380
dependencies curl git go jq make pnpm
9481

@@ -241,9 +228,9 @@ fatal() {
241228
) || echo "Failed to start external provisioner. No external provisioner started."
242229
fi
243230

244-
# If we have docker available and the "docker" template doesn't already
231+
# If we have docker available and the "tasks-docker" template doesn't already
245232
# exist, then let's try to create a template!
246-
template_name="docker"
233+
template_name="tasks-docker"
247234
# Determine the name of the default org with some jq hacks!
248235
first_org_name=$("${CODER_DEV_SHIM}" organizations show me -o json | jq -r '.[] | select(.is_default) | .name')
249236
if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then
@@ -252,55 +239,31 @@ fatal() {
252239
echo "Waiting for terraform to be installed..."
253240
sleep 5
254241

255-
echo "Initializing docker template..."
242+
echo "Initializing tasks-docker template..."
243+
244+
# Pull the container image in the background to speed up workspace creation
245+
container_image="codercom/example-universal:ubuntu"
246+
echo "Pulling container image ${container_image} in background..."
247+
docker pull "${container_image}" >/dev/null 2>&1 &
248+
249+
# Create template from the examples directory
256250
temp_template_dir="$(mktemp -d)"
257-
"${CODER_DEV_SHIM}" templates init --id "${template_name}" "${temp_template_dir}"
251+
cp -r "${PROJECT_ROOT}/examples/templates/tasks-docker/"* "${temp_template_dir}/"
252+
258253
# Run terraform init so we get a terraform.lock.hcl
259254
pushd "${temp_template_dir}" && terraform init && popd
260255

261256
DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
262-
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
257+
printf 'docker_socket: "%s"\n' "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
263258
(
264-
echo "Pushing docker template to '${first_org_name}'..."
259+
echo "Pushing tasks-docker template to '${first_org_name}'..."
265260
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}"
266261
if [ "${multi_org}" -gt "0" ]; then
267-
echo "Pushing docker template to '${another_org}'..."
262+
echo "Pushing tasks-docker template to '${another_org}'..."
268263
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}"
269264
fi
270265
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
271-
) || echo "Failed to create a template. The template files are in ${temp_template_dir}"
272-
fi
273-
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-
printf 'docker_socket: "%s"\n' "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
294-
(
295-
echo "Pushing tasks-docker template to '${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}"
297-
if [ "${multi_org}" -gt "0" ]; then
298-
echo "Pushing tasks-docker template to '${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}"
300-
fi
301-
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
302-
) || echo "Failed to create tasks-docker template. The template files are in ${temp_template_dir}"
303-
fi
266+
) || echo "Failed to create tasks-docker template. The template files are in ${temp_template_dir}"
304267
fi
305268

306269
if [ "${use_proxy}" -gt "0" ]; then

0 commit comments

Comments
 (0)