@@ -8,6 +8,7 @@ SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
88# shellcheck disable=SC1091
99source " ${SCRIPT_DIR} /lib.sh"
1010PROJECT_ROOT=$( cd " $SCRIPT_DIR " && git rev-parse --show-toplevel)
11+ CODER_DEV_BIN=" ${PROJECT_ROOT} /.coderv2/coder"
1112set +u
1213CODER_DEV_ADMIN_PASSWORD=" ${CODER_DEV_ADMIN_PASSWORD:- password} "
1314set -u
@@ -27,6 +28,11 @@ if [[ ! -e ./site/out/bin/coder.sha1 && ! -e ./site/out/bin/coder.tar.zst ]]; th
2728 exit 1
2829fi
2930
31+ # Compile the CLI binary once just so we don't waste time compiling things multiple times
32+ go build -o " ${CODER_DEV_BIN} " " ${PROJECT_ROOT} /cmd/coder"
33+ # Use the coder dev shim so we don't overwrite the user's existing Coder config.
34+ CODER_DEV_SHIM=" ${PROJECT_ROOT} /scripts/coder-dev.sh"
35+
3036# Run yarn install, to make sure node_modules are ready to go
3137" $PROJECT_ROOT /scripts/yarn_install.sh"
3238
3642(
3743 # If something goes wrong, just bail and tear everything down
3844 # rather than leaving things in an inconsistent state.
39- trap ' kill -INT -$$' ERR
45+ trap ' kill -TERM -$$' ERR
4046 cdroot
4147 CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
42- go run -tags embed cmd/coder/main.go server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ &
48+ " ${CODER_DEV_SHIM} " server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ &
4349
4450 echo ' == Waiting for Coder to become ready'
4551 timeout 60s bash -c ' until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done'
4652
4753 # create the first user, the admin
48- go run cmd/coder/main.go login http://127.0.0.1:3000 --username=admin
[email protected] --password=
" ${CODER_DEV_ADMIN_PASSWORD} " || 54+ " ${CODER_DEV_SHIM} " login http://127.0.0.1:3000 --username=admin
[email protected] --password=
" ${CODER_DEV_ADMIN_PASSWORD} " || 4955 echo ' Failed to create admin user. To troubleshoot, try running this command manually.'
5056
5157 # || true to always exit code 0. If this fails, whelp.
52- go run cmd/coder/main.go users create
[email protected] --username=member --password=
" ${CODER_DEV_ADMIN_PASSWORD} " || 58+ " ${CODER_DEV_SHIM} " users create
[email protected] --username=member --password=
" ${CODER_DEV_ADMIN_PASSWORD} " || 5359 echo ' Failed to create regular user. To troubleshoot, try running this command manually.'
5460
5561 # If we have docker available, then let's try to create a template!
5662 template_name=" "
5763 if docker info > /dev/null 2>&1 ; then
5864 temp_template_dir=$( mktemp -d)
59- echo code-server | go run " ${PROJECT_ROOT} /cmd/coder/main.go " templates init " ${temp_template_dir} "
65+ echo code-server | " ${CODER_DEV_SHIM} " templates init " ${temp_template_dir} "
6066 # shellcheck disable=SC1090
6167 source <( go env | grep GOARCH)
6268 DOCKER_HOST=$( docker context inspect --format ' {{.Endpoints.docker.Host}}' )
6369 printf ' docker_arch: "%s"\ndocker_host: "%s"\n' " ${GOARCH} " " ${DOCKER_HOST} " | tee " ${temp_template_dir} /params.yaml"
6470 template_name=" docker-${GOARCH} "
65- go run " ${PROJECT_ROOT} /cmd/coder/main.go " templates create " ${template_name} " --directory " ${temp_template_dir} " --parameter-file " ${temp_template_dir} /params.yaml" --yes
71+ " ${CODER_DEV_SHIM} " templates create " ${template_name} " --directory " ${temp_template_dir} " --parameter-file " ${temp_template_dir} /params.yaml" --yes
6672 rm -rfv " ${temp_template_dir} "
6773 fi
6874
7581 if [[ -n " ${template_name} " ]]; then
7682 log " == =="
7783 log " == Docker template ${template_name} is ready to use! =="
84+ log " == Use ./scripts/coder-dev.sh to talk to this instance! =="
7885 log " == =="
7986 fi
8087 log " ======================================================================="
0 commit comments