From 69d6bbc0d6f15ae9b5f5609f1c8c6487546dbadd Mon Sep 17 00:00:00 2001 From: Dusan Mitrovic Date: Tue, 3 Dec 2019 11:25:29 +0100 Subject: [PATCH] Add script --- .scripts/deploy_hob_binaries | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 .scripts/deploy_hob_binaries diff --git a/.scripts/deploy_hob_binaries b/.scripts/deploy_hob_binaries new file mode 100755 index 0000000..5c4ea06 --- /dev/null +++ b/.scripts/deploy_hob_binaries @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Description: A script to automate the copying of HoB binaries into their docker containers +# Author: Dusan Mitrovic +# Version: 1.0 +# _ _ ____ _ +# | | | | ___ | __ ) / \ _ __ _ __ ___ +# | |_| |/ _ \| _ \ / _ \ | '_ \| '_ \/ __| +# | _ | (_) | |_) / ___ \| |_) | |_) \__ \ +# |_| |_|\___/|____/_/ \_\ .__/| .__/|___/ +# |_| |_| + + +HOB_BINARIES_DIRECTORY="/root/hob-binaries" +HOB_BINARIES_DOCKER_DIRECTORY="/server/static/binaries/hob" + +HOB_WIN_64="$HOB_BINARIES_DIRECTORY/house-of-benefits-win.exe" +HOB_LINUX="$HOB_BINARIES_DIRECTORY/house-of-benefits-linux.AppImage" + +HOB_DOCKER_WIN_64="$HOB_BINARIES_DOCKER_DIRECTORY/win64/" +HOB_DOCKER_LINUX="$HOB_BINARIES_DOCKER_DIRECTORY/linux/" + +get_production_docker_container_id() { + PRODUCTION_CONTAINER_ID="$(docker ps | grep api.hob | awk '/^34/ {print $1}')" +} + +get_staging_docker_container_id() { + STAGING_CONTAINER_ID="$(docker ps | grep staging.api.hob | awk '{print $1}')" +} + +deploy() { + get_production_docker_container_id + get_staging_docker_container_id + + declare -a PATHS + declare -a DOCKER_PATHS + + PATHS=( $HOB_WIN_64 $HOB_LINUX ) + DOCKER_PATHS=( $HOB_DOCKER_WIN_64 $HOB_DOCKER_LINUX ) + + # Deploy staging + echo "--COPY STAGING START--" + for index in ${!PATHS[*]} + do + echo "Copying ${PATHS[$index]}" + docker cp ${PATHS[$index]} ${STAGING_CONTAINER_ID}:${DOCKER_PATHS[$index]} + done + echo "--COPY STAGING COMPLETE--" + + # Deploy production + echo "--COPY PRODUCTION START--" + for index in ${!PATHS[*]} + do + echo "Copying ${PATHS[$index]}" + docker cp ${PATHS[$index]} ${PRODUCTION_CONTAINER_ID}:${DOCKER_PATHS[$index]} + done + echo "--COPY PRODUCTION COMPLETE--" + } + +deploy