From 5443712115e3a2f6592f3188fcbc3f46745e5192 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Wed, 30 Oct 2024 19:21:26 +0300 Subject: [PATCH] add action to build docker image files --- .github/workflows/build-installer.yml | 49 +++++++++++++++++ build.sh | 79 +++++++++++++++++++++++++++ install/loadImages.sh | 11 ++++ 3 files changed, 139 insertions(+) create mode 100644 .github/workflows/build-installer.yml create mode 100755 build.sh create mode 100755 install/loadImages.sh diff --git a/.github/workflows/build-installer.yml b/.github/workflows/build-installer.yml new file mode 100644 index 0000000..28783fe --- /dev/null +++ b/.github/workflows/build-installer.yml @@ -0,0 +1,49 @@ +name: Build OpenELIS-Global-2 Docker Images +on: + release: + types: [published] + +jobs: + build-installer-and-upload-installer: + runs-on: ubuntu-latest + steps: + + - name: Checkout OpenELIS-Global2 + uses: actions/checkout@v2 + with: + repository: ${{github.repository}} + + - name: Build installer + run: ./build.sh ${{ github.ref_name }} + + - name: check installer + run: ls OEDockerImages + + + - name: Find installer file + id: find_file + run: | + # Find the file in OEDockerImages with .tar.gz extension + FILE_PATH=$(find OEDockerImages -name "*.tar.gz" -print -quit) + if [ -z "$FILE_PATH" ]; then + echo "No .tar.gz file found in OEDockerImages directory." + exit 1 + fi + echo "File path: $FILE_PATH" + # Extract the file name from the path + FILE_NAME=$(basename "$FILE_PATH") + echo "File name: $FILE_NAME" + # Pass the file path and name to outputs + echo "FILE_PATH=$FILE_PATH" >> $GITHUB_ENV + echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ env.FILE_PATH }} + asset_name: ${{ env.FILE_NAME }} + asset_content_type: application/gzip + diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..26efdcd --- /dev/null +++ b/build.sh @@ -0,0 +1,79 @@ +#!/bin/bash +projectVersion=${1:-"latest"} +INSTALLER_CREATION_DIR="OEDockerImages " + +if [ -d "${INSTALLER_CREATION_DIR}" ] +then + while true; do + read -p "Installer directory has been detected, replace it? [Y]es [N]o: " yn + case $yn in + [Yy][Ee][Ss]|[Yy] ) break;; + [Nn][Oo]|[Nn] ) exit;; + * ) echo "Please answer yes or no.";; + esac + done + rm -r ${INSTALLER_CREATION_DIR} +fi + +echo "creating docker images" + +createLinuxInstaller() { + context="OpenELIS-Global " + installerName="${context}_${projectVersion}_dockerImages" + + echo "creating installer for context ${context}" + mkdir -p ${INSTALLER_CREATION_DIR}/${installerName} + cp ./install/loadImages.sh ${INSTALLER_CREATION_DIR}/${installerName}/loadImages.sh + cp OpenELIS-Global_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/OpenELIS-Global_DockerImage.tar.gz + cp Postgres_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/Postgres_DockerImage.tar.gz + cp JPAServer_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/JPAServer_DockerImage.tar.gz + cp AutoHeal_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/AutoHeal_DockerImage.tar.gz + cp NGINX_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/NGINX_DockerImage.tar.gz + cp ReactFrontend_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/ReactFrontend_DockerImage.tar.gz + cp Certs_DockerImage.tar.gz ${INSTALLER_CREATION_DIR}/${installerName}/dockerImage/Certs_DockerImage.tar.gz + + cd ${INSTALLER_CREATION_DIR} + tar -cf ${installerName}.tar ${installerName} + gzip ${installerName}.tar +} + + +echo "saving docker image as OpenELIS-Global_DockerImage.tar.gz" +docker pull itechuw/openelis-global-2:develop +docker save itechuw/openelis-global-2:develop | gzip > OpenELIS-Global_DockerImage.tar.gz + +echo "saving React frontend docker image" +docker pull itechuw/openelis-global-2-frontend:develop +docker save itechuw/openelis-global-2-frontend:develop | gzip > ReactFrontend_DockerImage.tar.gz + +echo "saving JPA Server docker image" +docker pull itechuw/openelis-global-2-fhir:develop +docker save itechuw/openelis-global-2-fhir:develop | gzip > JPAServer_DockerImage.tar.gz + +echo "saving Postgres docker image" +docker pull postgres:14.4 +docker save postgres:14.4 | gzip > Postgres_DockerImage.tar.gz + +echo "saving Autoheal docker image" +docker pull willfarrell/autoheal:1.2.0 +docker save willfarrell/autoheal:1.2.0 | gzip > AutoHeal_DockerImage.tar.gz + +echo "saving NGINX docker image" +docker pull itechuw/openelis-global-2-proxy:develop +docker save itechuw/openelis-global-2-proxy:develop | gzip > NGINX_DockerImage.tar.gz + +echo "saving Certs docker image" +docker pull itechuw/certgen:main +docker save itechuw/certgen:main | gzip > Certs_DockerImage.tar.gz + + +createLinuxInstaller + +rm OpenELIS-Global_DockerImage*.tar.gz +rm Postgres_DockerImage.tar.gz +rm JPAServer_DockerImage.tar.gz +rm AutoHeal_DockerImage.tar.gz +rm NGINX_DockerImage.tar.gz +rm ReactFrontend_DockerImage.tar.gz +rm Certs_DockerImage.tar.gz + diff --git a/install/loadImages.sh b/install/loadImages.sh new file mode 100755 index 0000000..3a67da6 --- /dev/null +++ b/install/loadImages.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cd dockerImage +gunzip -c OpenELIS-Global_DockerImage.tar.gz | docker load +gunzip -c Postgres_DockerImage.tar.gz | docker load +gunzip -c JPAServer_DockerImage.tar.gz | docker load +gunzip -c AutoHeal_DockerImage.tar.gz | docker load +gunzip -c NGINX_DockerImage.tar.gz | docker load +gunzip -c ReactFrontend_DockerImage.tar.gz | docker load +gunzip -c Certs_DockerImage.tar.gz | docker load + +