summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun.sh (renamed from build_docker.sh)48
1 files changed, 44 insertions, 4 deletions
diff --git a/build_docker.sh b/run.sh
index da10c3e..998e81d 100755
--- a/build_docker.sh
+++ b/run.sh
@@ -2,12 +2,49 @@
cd "${0%/*}" || exit 1
+
+
# set the default Docker image tag to dactyl-keyboard
IMAGE_TAG="dactyl-keyboard"
# by default, don't rebuild the image
REBUILD=false;
+# get the command the user would like to run
+COMMAND=${1:?A command is required. Try \'run help\'}
+
+case $COMMAND in
+ help)
+ echo "Usage:"
+ echo " run [command]"
+ echo ""
+ echo "Available Commands:"
+ echo " help show this help"
+ echo " generate output the keyboard files to the 'things' directory"
+ echo " configure "
+ echo " release "
+ echo ""
+ echo "Flags:"
+ echo " -r rebuild the docker image"
+ echo " -i the tag that should be applied to the docker image"
+ exit 0
+ ;;
+ generate)
+ SCRIPT=dactyl_manuform.py
+ ;;
+ configure)
+ SCRIPT=generate_configuration.py
+ ;;
+ release)
+ SCRIPT=model_builder.py
+ ;;
+ *)
+ echo "Invalid command. Try 'run help'"
+ exit 1
+esac
+
+
+
# check for command line flags
while getopts 'ri:' flag; do
case "${flag}" in
@@ -25,10 +62,13 @@ if $REBUILD || [ $INSPECT_RETURN_CODE -ne 0 ]; then
docker build -t ${IMAGE_TAG} -f docker/Dockerfile .
fi
-# run each of the dactyl commands in temporary containers
-docker run --name dm-run -d --rm -v "`pwd`/src:/app/src" -v "`pwd`/things:/app/things" ${IMAGE_TAG} python3 -i dactyl_manuform.py > /dev/null 2>&1
-docker run --name dm-config -d --rm -v "`pwd`/:/app/src" -v "`pwd`/things:/app/things" ${IMAGE_TAG} python3 -i generate_configuration.py > /dev/null 2>&1
-docker run --name dm-release-build -d --rm -v "`pwd`/:/app/src" -v "`pwd`/things:/app/things" ${IMAGE_TAG} python3 -i model_builder.py > /dev/null 2>&1
+
+
+
+# run the command in a temporary container
+docker run --name dm-run -d --rm -v "`pwd`/src:/app/src" -v "`pwd`/things:/app/things" ${IMAGE_TAG} python3 -i $SCRIPT > /dev/null 2>&1
+
+
# show progress indicator while until dm-run container completes
while $(docker inspect --format={{.Id}} dm-run > /dev/null 2>&1); do