add ability to build local variants from a ./.code directory

This commit is contained in:
Dietrich Rink
2023-06-10 15:50:08 +02:00
parent b3216433c4
commit 6d0bf0957f
2 changed files with 15 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
set -euo pipefail
shopt -s extglob
cd "$(dirname "$0")"
readonly DIR="$(cd "$(dirname "$0")"; pwd)"
if (( $# == 0 )); then
readonly images=(core basic !(template|core|basic)/)
@@ -11,5 +11,13 @@ else
fi
for image in "${images[@]}"; do
podman build -t "code-${image%/}" -f "${image%/}/Containerfile"
if [[ "$image" == '.' ]]; then
tag="$(basename "$(pwd)")"
contdir='.code'
else
tag="$image"
contdir="$DIR/${image%/}"
fi
podman build -t "code-${tag}" -f "${contdir}/Containerfile"
done

11
code
View File

@@ -25,19 +25,18 @@ readonly DIR="$(dirname "$(readlink -f -- "$0")")"
ports=()
loopback=false
variant="$DEFAULT_VARIANT"
variants=($(
podman image list code- -n | sed -n 's|^[^ ]\+/code-\([^ ]\+\) .*|\1|p'
))
for arg in "$@"; do
case "$arg" in
--publish ) shift; ports+=("$1");;
--loopback ) loopback=true;;
--variants )
for f in "$DIR"/*; do
[[ "$f" == */template || ! -d "$f" ]] || echo "${f##*/}";
done
exit;;
--variants ) printf '%s\n' "${variants[@]}"; exit;;
-h | --help ) echo >&2 "$HELP"; exit;;
--* )
if [[ ! -d "${DIR}/${arg#--}" ]]; then break; fi
[[ " ${variants[*]} " == *" ${arg#--} "* ]] || break
variant="${arg#--}";;
* ) break;;
esac