Skip to content

Instantly share code, notes, and snippets.

@pmundt
Last active July 28, 2020 15:08
Show Gist options
  • Save pmundt/0030687f8eb18fec98405d838ce56e87 to your computer and use it in GitHub Desktop.
Save pmundt/0030687f8eb18fec98405d838ce56e87 to your computer and use it in GitHub Desktop.
SODALITE Image Builder CLI Wrapper
#!/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