Skip to content
Snippets Groups Projects
Commit 7f2767c0 authored by GARION Christophe's avatar GARION Christophe
Browse files

[scripts] refactor script to launch docker

parent 3b482498
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
containerId=leliobrun/lustrec-env
command -v docker >/dev/null 2>&1 || { \
echo >&2 "docker is required but could not be found. Aborting."; \
echo >&2 "To setup Docker: https://docs.docker.com/engine/getstarted/step_one/"; \
exit 1; }
docker run -it --rm --user $(id -u):$(id -g)\
-v $PWD:/home/opam/lustrec $containerId $1
#!/usr/bin/env bash
# shell script to launch LustreC docker, mainly for launching tests
# see the usage function for more explanations
# usage function
usage () {
echo "Usage: " $0 " [-h|--help] [-i|--id ID] [-t|--tmp TMP_DIR] [options passed to docker]"
echo " Run a docker instance named \"lustrec_docker\" built with image " $CONTAINER_ID " by default."
echo " Available options:"
echo " - [-i|--id ID] | change container image ID"
echo " - [-t|--tmp TMP_DIR] | change binding for /tmp dir in container. Default to /tmp"
exit 1
}
# default values
CONTAINER_ID=leliobrun/lustrec-env
TMP_DIR=/tmp
# use getopt to get arguments
TEMP=$(getopt -o 'hi:t:' --long 'help,id:,tmp:' -n 'rundocker.sh' -- "$@")
eval set -- "$TEMP"
unset TEMP
# main loop to get arguments
while true; do
case "$1" in
'-h'|'--help')
usage
;;
'-i'|'--id')
CONTAINER_ID="$2"
shift 2
continue
;;
'-t'|'--tmp')
TMP_DIR="$2"
shift 2
continue
;;
*)
shift
break
;;
esac
done
# check if docker is available
command -v docker >/dev/null 2>&1 || { \
echo >&2 "docker is required but could not be found. Aborting."; \
echo >&2 "To setup Docker: https://docs.docker.com/engine/getstarted/step_one/"; \
exit 1; }
# launch docker
docker run -it --rm --user $(id -u):$(id -g)\
-name "lustrec_docker" \
-v ${TMP_DIR}:/tmp -v ${PWD}:/home/opam/lustrec \
${CONTAINER_ID} $@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment