Skip to content

Commit

Permalink
chore: set quickstart.sh to attach by default (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
lamchau authored Jan 16, 2024
1 parent dec82af commit a567161
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Options
-h, --help show this help message and exit
-c, --commit=<hash> commit hash for `docker build` (default: HEAD)
-t, --tag=<tag> tag name for `docker build` (default: did-dht:latest)
-a, --attach run the container in the foreground (default: true)
-d, --detach run the container in the background (default: false)
-k, --keep keep the container after it exits (default: false)
-n, --name=<name> name to give the container (default: did-dht-server)
-p, --port=<port> ports to publish the host/container (default: 8305:8305)
Expand Down
2 changes: 1 addition & 1 deletion impl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Options
-h, --help show this help message and exit
-c, --commit=<hash> commit hash for `docker build` (default: HEAD)
-t, --tag=<tag> tag name for `docker build` (default: did-dht:latest)
-a, --attach run the container in the foreground (default: true)
-d, --detach run the container in the background (default: false)
-k, --keep keep the container after it exits (default: false)
-n, --name=<name> name to give the container (default: did-dht-server)
-p, --port=<port> ports to publish the host/container (default: 8305:8305)
Expand Down
20 changes: 13 additions & 7 deletions scripts/quickstart.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

DEBUG_FLAG="false"

log() {
if [ "$#" -ge 2 ]; then
type="$1"
Expand Down Expand Up @@ -80,7 +81,7 @@ opt_commit_hash="$(git rev-parse HEAD)"
opt_tag="did-dht:latest"

# docker run
opt_detach="--detach"
opt_detach=""
opt_remove="--rm"
opt_name="did-dht-server"
opt_port="8305:8305"
Expand All @@ -98,7 +99,7 @@ for opt in "$@"; do
echo " -h, --help show this help message and exit"
echo " -c, --commit=<hash> commit hash for \`docker build\` (default: HEAD)"
echo " -t, --tag=<tag> tag name for \`docker build\` (default: did-dht:latest)"
echo " -a, --attach run the container in the foreground (default: true)"
echo " -d, --detach run the container in the background (default: false)"
echo " -k, --keep keep the container after it exits (default: false)"
echo " -n, --name=<name> name to give the container (default: did-dht-server)"
echo " -p, --port=<port> ports to publish the host/container (default: 8305:8305)"
Expand All @@ -118,8 +119,8 @@ for opt in "$@"; do
;;

# run options --------------------------------------------------------------
-a | --attach)
unset opt_detach
-d | --detach)
opt_detach="--detach"
shift
;;

Expand Down Expand Up @@ -190,12 +191,17 @@ if docker ps --all --format '{{.Names}}' | grep --quiet "$opt_name"; then
exit 1
fi

printf "info: running container "
if [ -z "$opt_detach" ]; then
info "running in foreground"
info "use ctrl-p ctrl-q to detach from the container (send to background)"
echo ""
fi

$_DEBUG docker run \
"$opt_detach" \
"$opt_remove" \
$opt_detach \
--interactive \
--tty \
--publish "$opt_port" \
--name "$opt_name" \
"$opt_remove" \
"$opt_tag"

0 comments on commit a567161

Please sign in to comment.