mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
The packaging script will create a new tar.bz2 archive containing an install script, a set of docker images, and a root folder with files to be installed. The root folder includes a systemd service, a docker compose file, an entry script, and a template config file. On installation docker images are loaded onto the target system, install files are copied, then systemd services are installed.
93 lines
2.2 KiB
Bash
Executable File
93 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# Copyright (C) Wendepunkt Medical Innovations, Inc - All Rights Reserved.
|
|
# Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
# Proprietary and confidential
|
|
#
|
|
# For information: dev@signalytic.ca
|
|
#
|
|
|
|
# basic path info
|
|
LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
PROJECT_ROOT="$(realpath $LOCATION)"
|
|
PACKAGE_NAME="streamline-emr"
|
|
OUTPUT_DIR="$PROJECT_ROOT/build-packages"
|
|
|
|
# work from the project root
|
|
pushd $PROJECT_ROOT > /dev/null
|
|
|
|
# Exit on error:
|
|
set -e
|
|
trap 'echo "Error: Last command failed with exit code $?."' ERR
|
|
|
|
# generate version name
|
|
# 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
|
|
# Note: commit count is harder to get to from CI - can't reproduce the git
|
|
# describe functionality as easily
|
|
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="unknown"
|
|
fi
|
|
|
|
OUTPUT_NAME="$PACKAGE_NAME-$VERSION_NAME-$(arch)"
|
|
OUTPUT_FILE="$OUTPUT_NAME.tar.bz2"
|
|
OUTPUT_PATH="$OUTPUT_DIR/$OUTPUT_FILE"
|
|
|
|
# create a new temp directory to stage files
|
|
for i in {1..9999};do
|
|
STAGING_DIR="tmp-staging-$i"
|
|
if [ ! -d $STAGING_DIR ]; then
|
|
break
|
|
fi
|
|
done
|
|
if [ -d $STAGING_DIR ]; then
|
|
echo "Failed to generate temp staging dir"
|
|
exit 1
|
|
fi
|
|
|
|
# add files
|
|
mkdir ${STAGING_DIR}
|
|
cp ${PROJECT_ROOT}/install.sh ${STAGING_DIR}/
|
|
cp -a ${PROJECT_ROOT}/root ${STAGING_DIR}/
|
|
|
|
# add images
|
|
IMAGES_DIR=${STAGING_DIR}/images
|
|
mkdir -p ${IMAGES_DIR}
|
|
i=0
|
|
for image in $(find root/ -name docker-compose.yml | xargs grep 'image:.*' | awk '{print $2}');do
|
|
i=$((i+1))
|
|
name="image${i}.img"
|
|
echo "addding '$name' -> '$image'"
|
|
docker pull $image
|
|
docker save -o ${IMAGES_DIR}/$name $image
|
|
done
|
|
|
|
# setup output directory and cleanup old files if necessary
|
|
mkdir -p $OUTPUT_DIR
|
|
rm -rf $OUTPUT_PATH
|
|
|
|
pushd $STAGING_DIR > /dev/null
|
|
tar -cjf $OUTPUT_PATH *
|
|
popd > /dev/null
|
|
|
|
# cleanup staging files
|
|
rm -r $STAGING_DIR
|
|
|
|
echo "output: $OUTPUT_PATH"
|
|
|
|
popd > /dev/null
|
|
|
|
exit 0
|