From a2c69b384acadba3c8593c9e3242c619841fc289 Mon Sep 17 00:00:00 2001 From: Casey Date: Fri, 12 Dec 2025 17:38:11 -0600 Subject: [PATCH] add to script for deployment --- build_new.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/build_new.sh b/build_new.sh index 8a6d1350..d60dcdbb 100755 --- a/build_new.sh +++ b/build_new.sh @@ -1,7 +1,83 @@ -export TAG=1.1.10 +#!/bin/bash + +TAG="" +REMOTE_HOST="erpnext.lasthourhosting.org" +REMOTE_USER="root" +MIGRATE=false + +while [[ $# -gt 0 ]]; do + case "$1" in + --tag) + if [[ -z "${2:-}" ]]; then + echo "Error: --tag requires a value" + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 1 + fi + TAG="$2" + shift 2 + ;; + --migrate) + MIGRATE=true + shift 1 + ;; + --remote-host) + if [[ -z "${2:-}" ]]; then + echo "Error: --remote-host requires a value" + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 1 + fi + REMOTE_HOST="$2" + shift 2 + ;; + --remote-user) + if [[ -z "${2:-}" ]]; then + echo "Error: --remote-user requires a value" + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 1 + fi + REMOTE_USER="$2" + shift 2 + ;; + -h|--help) + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 0 + ;; + *) + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 1 + ;; + esac +done + +if [[ -z "$TAG" ]]; then + echo "Error: --tag is required" + echo "Usage: $0 [--tag ] [--remote-host ] [--remote-user ]" + exit 1 +fi + +export TAG +export APPS_JSON_BASE64=$(base64 -w 0 ./apps_new.json) +echo "Building Brotherton Frappe Docker Image with tag: $TAG" +echo "APPS_JSON_BASE64: $APPS_JSON_BASE64" +echo "🚀 Starting Docker build..." docker build --no-cache \ --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \ --build-arg=FRAPPE_BRANCH=version-15 \ --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \ --tag=githaven.org/shiloh/brotherton_frappe_docker:$TAG \ --file=images/layered/Containerfile . + +echo "✅ Docker build completed!" +echo "📤 Pushing image to registry..." +docker push githaven.org/shiloh/brotherton_frappe_docker:$TAG + +echo "✅ Image pushed successfully!" +MIGRATE_COMMAND="" +if [ "$MIGRATE" = true ]; then + MIGRATE_COMMAND="--migrate" + +if [[ -n "$REMOTE_HOST" ]]; then + echo "🔗 Connecting to remote server $REMOTE_USER@$REMOTE_HOST..." + ssh "$REMOTE_USER@$REMOTE_HOST" "./re-deploy.sh --tag $TAG $MIGRATE_COMMAND" + echo "✅ Remote deployment completed!" +fi \ No newline at end of file