Skip to content

Commit 344a46d

Browse files
committed
add option to choose program to run the container (--runcmd)
if parameter is not set, it looks for podman,orbstack and docker
1 parent 0d40644 commit 344a46d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

evb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ available options:
3333
run VoxBox with -e SPEC=spec/classes/supermodule_spec.rb
3434
--volume vol : specify an additional volume to put into the container
3535
see podman man page how to specify 'vol'. (no path magic is done ;))
36+
--runcmd : this lets you change the program used to start the container
37+
if not set explicit it looks for podman, orbstack and finally docker.
3638
3739
available command:
3840
help : print this help message and exit
@@ -45,7 +47,7 @@ EOF
4547

4648
run_container () {
4749
P=$(get_path $PWD)
48-
command="podman run -it --rm $(sed "s|=${P}/|=|g" <<< "${PODENV}") -v ${P}:/repo:Z ${PODOPTIONS} ${PODIMAGE} ${VOXBOXCOMMAND}"
50+
command="${RUNCMD} run -it --rm $(sed "s|=${P}/|=|g" <<< "${PODENV}") -v ${P}:/repo:Z ${PODOPTIONS} ${PODIMAGE} ${VOXBOXCOMMAND}"
4951
if [ ${NOOP} -eq 0 ] ; then
5052
${command}
5153
else
@@ -55,6 +57,7 @@ run_container () {
5557
fi
5658
}
5759

60+
5861
# get options
5962
NOOP=0
6063
PODOPTIONS=''
@@ -71,6 +74,11 @@ while [[ $# -gt 0 ]]; do
7174
NOOP=1
7275
shift
7376
;;
77+
--runcmd)
78+
shift
79+
RUNCMD=${1}
80+
shift
81+
;;
7482
--entrypoint)
7583
shift
7684
PODOPTIONS="--entrypoint ${1} ${PODOPTIONS}"
@@ -98,4 +106,18 @@ while [[ $# -gt 0 ]]; do
98106
esac
99107
done
100108

109+
# lets see what we have as default runcmd:
110+
if [ -n "${RUNCMD}" ] ; then
111+
true
112+
elif [ -n $(which podman) ] ; then
113+
RUNCMD='podman'
114+
elif [ -n $(which orbstack) ] ; then
115+
RUNCMD='orbstack'
116+
elif [ -n $(which docker) ] ; then
117+
RUNCMD='docker'
118+
else
119+
echo "ERROR: could not find podman/orbstack or docker to start container" >&2
120+
exit 200
121+
fi
122+
101123
run_container

0 commit comments

Comments
 (0)