@@ -8,6 +8,7 @@ SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
8
8
# shellcheck disable=SC1091
9
9
source " ${SCRIPT_DIR} /lib.sh"
10
10
PROJECT_ROOT=$( cd " $SCRIPT_DIR " && git rev-parse --show-toplevel)
11
+ CODER_DEV_BIN=" ${PROJECT_ROOT} /.coderv2/coder"
11
12
set +u
12
13
CODER_DEV_ADMIN_PASSWORD=" ${CODER_DEV_ADMIN_PASSWORD:- password} "
13
14
set -u
@@ -27,6 +28,11 @@ if [[ ! -e ./site/out/bin/coder.sha1 && ! -e ./site/out/bin/coder.tar.zst ]]; th
27
28
exit 1
28
29
fi
29
30
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
+
30
36
# Run yarn install, to make sure node_modules are ready to go
31
37
" $PROJECT_ROOT /scripts/yarn_install.sh"
32
38
36
42
(
37
43
# If something goes wrong, just bail and tear everything down
38
44
# rather than leaving things in an inconsistent state.
39
- trap ' kill -INT -$$' ERR
45
+ trap ' kill -TERM -$$' ERR
40
46
cdroot
41
47
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 -$$ &
43
49
44
50
echo ' == Waiting for Coder to become ready'
45
51
timeout 60s bash -c ' until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done'
46
52
47
53
# 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} " ||
49
55
echo ' Failed to create admin user. To troubleshoot, try running this command manually.'
50
56
51
57
# || 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} " ||
53
59
echo ' Failed to create regular user. To troubleshoot, try running this command manually.'
54
60
55
61
# If we have docker available, then let's try to create a template!
56
62
template_name=" "
57
63
if docker info > /dev/null 2>&1 ; then
58
64
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} "
60
66
# shellcheck disable=SC1090
61
67
source <( go env | grep GOARCH)
62
68
DOCKER_HOST=$( docker context inspect --format ' {{.Endpoints.docker.Host}}' )
63
69
printf ' docker_arch: "%s"\ndocker_host: "%s"\n' " ${GOARCH} " " ${DOCKER_HOST} " | tee " ${temp_template_dir} /params.yaml"
64
70
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
66
72
rm -rfv " ${temp_template_dir} "
67
73
fi
68
74
75
81
if [[ -n " ${template_name} " ]]; then
76
82
log " == =="
77
83
log " == Docker template ${template_name} is ready to use! =="
84
+ log " == Use ./scripts/coder-dev.sh to talk to this instance! =="
78
85
log " == =="
79
86
fi
80
87
log " ======================================================================="
0 commit comments