-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(scripts): create both docker and tasks-docker templates by default for develop.sh #21184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
01a4c08
c5f9e30
c575b84
f98cf44
397efa8
8b5fa35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,26 @@ fatal() { | |
| echo "== FAIL: $*" >&2 | ||
| kill -INT $ppid >/dev/null 2>&1 | ||
| } | ||
| push_template() { | ||
| local template_name=$1 | ||
| local temp_template_dir=$2 | ||
| local first_org_name=$3 | ||
| local another_org=$4 | ||
| local params_file="${temp_template_dir}/params.yaml" | ||
|
|
||
| local push_args="--directory ${temp_template_dir}" | ||
| if [ -f "${params_file}" ]; then | ||
| push_args="${push_args} --variables-file ${params_file}" | ||
| fi | ||
|
|
||
| echo "Pushing ${template_name} template to '${first_org_name}'..." | ||
| "${CODER_DEV_SHIM}" templates push "${template_name}" ${push_args} --yes --org "${first_org_name}" | ||
| if [ "${multi_org}" -gt "0" ]; then | ||
| echo "Pushing ${template_name} template to '${another_org}'..." | ||
| "${CODER_DEV_SHIM}" templates push "${template_name}" ${push_args} --yes --org "${another_org}" | ||
| fi | ||
| rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds | ||
| } | ||
|
|
||
| # This is a way to run multiple processes in parallel, and have Ctrl-C work correctly | ||
| # to kill both at the same time. For more details, see: | ||
|
|
@@ -248,16 +268,37 @@ fatal() { | |
| 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" | ||
| ( | ||
| echo "Pushing docker template to '${first_org_name}'..." | ||
| "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}" | ||
| if [ "${multi_org}" -gt "0" ]; then | ||
| echo "Pushing docker template to '${another_org}'..." | ||
| "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}" | ||
| fi | ||
| rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds | ||
| push_template "${template_name}" "${temp_template_dir}" "${first_org_name}" "${another_org}" | ||
| ) || echo "Failed to create a template. The template files are in ${temp_template_dir}" | ||
| fi | ||
|
|
||
| # Also create the tasks-docker template if docker is available | ||
| template_name="tasks-docker" | ||
| if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then | ||
bpmct marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # sometimes terraform isn't installed yet when we go to create the | ||
| # template | ||
| echo "Waiting for terraform to be installed..." | ||
| sleep 5 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be a (bounded) loop with |
||
|
|
||
| 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 | ||
|
Comment on lines
+277
to
+300
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not make the regular |
||
|
|
||
| if [ "${use_proxy}" -gt "0" ]; then | ||
| log "Using external workspace proxy" | ||
| ( | ||
|
|
||
There was a problem hiding this comment.
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.