develop.sh: attempt to create a Docker template automatically (#2627)

This commit makes the following changes:

- Adds two variables docker_host and docker_arch to the example docker-code-server template
- Adds an example params.yaml to docker-code-server and updates the README.md to reference these parameters
- scripts/develop.sh will now attempt to create a template using docker-code-server with the appropriate parameters for the environment
- Updated Lima example to make use of the template parameters for docker-code-server


Additional drive-bys:

- webpack.dev.ts references CODER_HOST and not CODERV2_HOST; updated develop.sh accordingly
- develop.sh should now terminate child processes upon error.
This commit is contained in:
Cian Johnston
2022-06-27 09:59:08 +01:00
committed by GitHub
parent f9d830a2b6
commit bbbd5241c3
6 changed files with 82 additions and 14 deletions
+10 -7
View File
@@ -97,13 +97,16 @@ provision:
# Set up initial user
[ ! -e ~/.config/coderv2/session ] && coder login http://localhost:3000 --username admin --email admin@coder.com --password $(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8 | tee ${HOME}/.config/coderv2/password)
# Create an initial template
cd ${HOME}
echo code-server | coder templates init
cd ./docker-code-server
if [ $(arch) = "aarch64" ]; then
sed -i 's/arch.*=.*"amd64"/arch = "arm64"/' ./main.tf
temp_template_dir=$(mktemp -d)
echo code-server | coder templates init "${temp_template_dir}"
DOCKER_ARCH="amd64"
if [ "$(arch)" = "aarch64" ]; then
DOCKER_ARCH="arm64"
fi
coder templates create docker-code-server -y -d .
DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}')
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${DOCKER_ARCH}" "${DOCKER_HOST}" | tee "${temp_template_dir}/params.yaml"
coder templates create "docker-code-server-${DOCKER_ARCH}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes
rm -rfv "${temp_template_dir}"
probes:
- description: "docker to be installed"
script: |
@@ -127,7 +130,7 @@ probes:
See "/var/log/cloud-init-output.log" in the guest.
message: |
All Done! Your Coder instance is accessible at http://localhost:3000
Username: "admin@coder.com"
Password: Run `LIMA_INSTANCE=coder lima cat /home/${USER}.linux/.config/coderv2/password` 🤫