Skip to content

Commit

Permalink
Add script
Browse files Browse the repository at this point in the history
  • Loading branch information
dusnm committed Dec 3, 2019
1 parent 2782ed4 commit 69d6bbc
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .scripts/deploy_hob_binaries
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 69d6bbc

Please sign in to comment.