build.sh 974 Bytes
#!/bin/bash

set -e

TAG=test-latest
APP=moqui-app
PUSH_TO=docker://5.161.91.120:31234
PREFIX=
declare -a images=(moqui-jdbc-drivers moqui-app)

TOP_DIR="$(cd "$(dirname "$0")"; pwd -P)"

_build() {
	for image in "${images[@]}"; do
		docker buildx build --progress plain --build-context "moqui-builder=$TOP_DIR" -f "${TOP_DIR}/Dockerfile" --tag "${PREFIX}${image}:${TAG}" --target "${image}" "${APP}"
	done
}

_push() {
	for image in "${images[@]}"; do
		echo "Pushing ${PREFIX}${image}:${TAG} to ${PUSH_TO}/${image}:${TAG}"
		skopeo copy --dest-tls-verify=false "docker-daemon:${PREFIX}${image}:${TAG}" "${PUSH_TO}/${image}:${TAG}"
	done
}

while [[ $# -gt 0 ]]; do
	case "$1" in
		(--app)
			APP="$2"
			shift 2
			;;
		(--prefix)
			PREFIX="$2"
			shift 2
			;;
		(--push-to)
			PUSH_TO="$2"
			shift 2
			;;
		(--tag)
			TAG="$2"
			shift 2
			;;
		(*)
			break
			;;
	esac
done
case "$1" in
	(build)
		_build
		;;
	(push)
		_push
		;;
	("")
		_build
		_push
		;;
esac