Skip to content

Commit

Permalink
add action to build docker image files
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 committed Oct 30, 2024
1 parent b64c179 commit 5443712
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-installer.yml
Original file line number Diff line number Diff line change
@@ -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

79 changes: 79 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions install/loadImages.sh
Original file line number Diff line number Diff line change
@@ -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


0 comments on commit 5443712

Please sign in to comment.