Last active
July 28, 2020 15:08
-
-
Save pmundt/0030687f8eb18fec98405d838ce56e87 to your computer and use it in GitHub Desktop.
SODALITE Image Builder CLI Wrapper
This file contains 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
#!/bin/sh | |
[ $# != 1 ] && echo "Usage: $0 input-file.yaml" && exit 1 | |
get_abs_path() { | |
# $1 : relative path | |
[ ! -z $1 ] && echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" | |
} | |
input=$(get_abs_path $1) | |
get_extra_volume_mounts() { | |
# $1 : input file | |
local_dockerfile=$(get_abs_path $(grep file:\/\/ $1 | sed -e 's/^.*file:\/\///')) | |
local_build_context=$(get_abs_path $(grep path: $1 | sed -e 's/^.*path:[ \t]*//')) | |
extra_mounts="" | |
[ ! -z $local_dockerfile ] && extra_mounts="$extra_mounts -v $local_dockerfile:$local_dockerfile" | |
[ ! -z $local_build_context ] && extra_mounts="$extra_mounts -v $local_build_context:$local_build_context" | |
echo $extra_mounts | |
} | |
docker run -it -v $input:/input.yaml \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
$(get_extra_volume_mounts $1) \ | |
--net=host \ | |
sodaliteh2020/image-builder-cli |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment