mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 10:41:32 +00:00
Add image utils and bugfixes from kenya-emr
This commit is contained in:
+32
-11
@@ -12,14 +12,32 @@
|
||||
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
PROJECT_ROOT="$(realpath $LOCATION)"
|
||||
|
||||
# determine version name from git
|
||||
# use ci tag name if available (e.g. "v1.2")
|
||||
if [ $CI_COMMIT_TAG ]; then
|
||||
VERSION_NAME="$CI_COMMIT_TAG"
|
||||
# otherwise if ci, use BRANCH-COMMIT
|
||||
elif [ $CI_COMMIT_BRANCH ]; then
|
||||
VERSION_NAME="$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
||||
# if not ci, try to use git
|
||||
elif command -v git &> /dev/null; then
|
||||
VERSION_NAME=$(git describe --always --tags --dirty)
|
||||
# fallback
|
||||
else
|
||||
VERSION_NAME="latest"
|
||||
fi
|
||||
|
||||
# configurable options (override with env vars as needed)
|
||||
PACKAGE_NAME=${PACKAGE_NAME-"streamline-emr"}
|
||||
OUTPUT_DIR=${OUTPUT_DIR-"$PROJECT_ROOT/build-packages"}
|
||||
PACKAGE_IMAGES=${PACKAGE_IMAGES:-1}
|
||||
IMAGE_TAG=${IMAGE_TAG:-${VERSION_NAME}}
|
||||
IMAGES_LIST=${IMAGES_LIST:-${PROJECT_ROOT}/images.csv}
|
||||
|
||||
echo "packaging $PACKAGE_NAME"
|
||||
echo " output dir: $OUTPUT_DIR"
|
||||
echo " package images: $PACKAGE_IMAGES"
|
||||
echo " image tag: $IMAGE_TAG"
|
||||
|
||||
# work from the project root
|
||||
pushd $PROJECT_ROOT > /dev/null
|
||||
@@ -88,17 +106,20 @@ for platform in "linux/amd64" "linux/arm64"; do
|
||||
i=0
|
||||
# read image list from file (e.g. 'images-aarch64')
|
||||
# images are listed as SAVED_TAG=SOURCE_IMAGE
|
||||
for image in $(cat ${PROJECT_ROOT}/images-${pkg_arch});do
|
||||
i=$((i+1))
|
||||
name="image${i}.img"
|
||||
path="${IMAGES_DIR}/${name}"
|
||||
IFS=\= read -r dest source <<< "${image}"
|
||||
echo "pulling image '${source}' (${platform})"
|
||||
docker pull --platform ${platform} ${source}
|
||||
echo "tagging image as '${dest}'"
|
||||
docker tag ${source} ${dest}
|
||||
echo "saving to '${path}'"
|
||||
docker save -o ${path} $dest
|
||||
for image in $(cat ${IMAGES_LIST});do
|
||||
IFS=, read -r img_platform dest source <<< "${image}"
|
||||
# package only if the platforms match
|
||||
if [ "${img_platform}" = "${platform}" ]; then
|
||||
echo "pulling image '${source}' (${platform})"
|
||||
docker pull --platform ${platform} ${source}:${IMAGE_TAG}
|
||||
echo "tagging image as '${dest}:latest'"
|
||||
docker tag ${source}:${IMAGE_TAG} ${dest}:latest
|
||||
i=$((i+1))
|
||||
name="image${i}.img"
|
||||
path="${IMAGES_DIR}/${name}"
|
||||
echo "saving to '${path}'"
|
||||
docker save -o ${path} ${dest}:latest
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "skipping image packaging as requested"
|
||||
|
||||
Reference in New Issue
Block a user