-
Notifications
You must be signed in to change notification settings - Fork 928
develop.sh: attempt to create a Docker template automatically #2627
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36cfebf
scripts/develop.sh: try to create a docker template if docker is avai…
johnstcn a3569fd
use variables instead of sedding
johnstcn f6f8a9c
add example parameters file
johnstcn bf2bb0b
fmt
johnstcn 8751537
Update scripts/develop.sh
johnstcn b4c9f1d
show if template was created
johnstcn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker_host: "unix:///var/run/docker.sock" | ||
docker_arch: "amd64" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,12 @@ fi | |
# 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 | ||
( | ||
SCRIPT_PID=$$ | ||
# If something goes wrong, just bail and tear everything down | ||
# rather than leaving things in an inconsistent state. | ||
trap 'kill -INT -$$' ERR | ||
cdroot | ||
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -${SCRIPT_PID} & | ||
go run -tags embed cmd/coder/main.go server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -${SCRIPT_PID} & | ||
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ & | ||
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. did this var change? 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. As far as I can tell it was always |
||
go run -tags embed cmd/coder/main.go server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ & | ||
|
||
echo '== Waiting for Coder to become ready' | ||
timeout 60s bash -c 'until curl -s --fail http://localhost:3000 > /dev/null 2>&1; do sleep 0.5; done' | ||
|
@@ -49,5 +51,34 @@ fi | |
# || true to always exit code 0. If this fails, whelp. | ||
go run cmd/coder/main.go users create --email=member@coder.com --username=member --password="${CODER_DEV_ADMIN_PASSWORD}" || | ||
echo 'Failed to create regular user. To troubleshoot, try running this command manually.' | ||
|
||
# If we have docker available, then let's try to create a template! | ||
template_name="" | ||
if docker info >/dev/null 2>&1; then | ||
temp_template_dir=$(mktemp -d) | ||
echo code-server | go run "${PROJECT_ROOT}/cmd/coder/main.go" templates init "${temp_template_dir}" | ||
# shellcheck disable=SC1090 | ||
source <(go env | grep GOARCH) | ||
DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}') | ||
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" | tee "${temp_template_dir}/params.yaml" | ||
template_name="docker-${GOARCH}" | ||
go run "${PROJECT_ROOT}/cmd/coder/main.go" templates create "${template_name}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes | ||
rm -rfv "${temp_template_dir}" | ||
fi | ||
|
||
log | ||
log "=======================================================================" | ||
log "== ==" | ||
log "== Coder is now running in development mode. ==" | ||
log "== API : http://localhost:3000 ==" | ||
log "== Web UI: http://localhost:8080 ==" | ||
if [[ -n "${template_name}" ]]; then | ||
log "== ==" | ||
log "== Docker template ${template_name} is ready to use! ==" | ||
log "== ==" | ||
fi | ||
log "=======================================================================" | ||
log | ||
# Wait for both frontend and backend to exit. | ||
wait | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.