2022-01-18 21:13:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2022-01-25 19:08:25 +00:00
|
|
|
EMAIL="${EMAIL:-admin@coder.com}"
|
|
|
|
USERNAME="${USERNAME:-admin}"
|
|
|
|
ORGANIZATION="${ORGANIZATION:-ACME-Corp}"
|
|
|
|
PASSWORD="${PASSWORD:-password}"
|
2022-01-18 21:13:19 +00:00
|
|
|
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
|
|
cd "${PROJECT_ROOT}"
|
|
|
|
|
2022-01-25 19:08:25 +00:00
|
|
|
# Helper to create an initial user
|
|
|
|
function create_initial_user() {
|
|
|
|
# TODO: We need to wait for `coderd` to spin up -
|
|
|
|
# need to replace with a deterministic strategy
|
|
|
|
sleep 5s
|
|
|
|
|
|
|
|
curl -X POST \
|
|
|
|
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
|
|
|
|
-H 'Content-Type:application/json' \
|
2022-01-25 21:22:56 +00:00
|
|
|
http://localhost:3000/api/v2/user
|
2022-01-25 19:08:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 21:13:19 +00:00
|
|
|
# Do initial build - a dev build for coderd.
|
|
|
|
# It's OK that we don't build the front-end before - because the front-end
|
|
|
|
# assets are handled by the `yarn dev` devserver.
|
|
|
|
make bin/coderd
|
|
|
|
|
|
|
|
# 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:
|
|
|
|
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
|
2022-01-25 19:08:25 +00:00
|
|
|
(trap 'kill 0' SIGINT; create_initial_user & CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd)
|