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 set -euo pipefail
shopt -s extglob shopt -s extglob
cd "$(dirname "$0")" readonly DIR="$(cd "$(dirname "$0")"; pwd)"
if (( $# == 0 )); then if (( $# == 0 )); then
readonly images=(core basic !(template|core|basic)/) readonly images=(core basic !(template|core|basic)/)
@@ -11,5 +11,13 @@ else
fi fi
for image in "${images[@]}"; do 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 done

11
code
View File

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