From 331029dd207d3a4906d26516f10485e80d9d5022 Mon Sep 17 00:00:00 2001 From: Xavier Frankline Date: Thu, 11 Apr 2024 20:06:34 +0300 Subject: [PATCH] updates: cleanup from feedback --- Makefile | 9 +++++++-- deploy.sh | 34 ++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index fa377e3..8631560 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,18 @@ .PHONY: build up down +IMAGE_TAG?=0.0.1 #set Image tag from release version + build: - docker-compose build + IMAGE_TAG=${IMAGE_TAG} docker-compose build up: - docker-compose up -d + IMAGE_TAG=${IMAGE_TAG} docker-compose up -d down: docker-compose down +deploy: + sudo ./deploy.sh + bash: docker-compose exec api sh diff --git a/deploy.sh b/deploy.sh index 60e8ee7..2c9b4de 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,7 +3,7 @@ # Environment variables -IMAGE_TAG="latest" # Change this based on deployment (staging, production, v1.0) - Reference tags in new-search-api Repo +IMAGE_TAG="v1.3.1" # Change this based on deployment (staging, production, v1.0) - Reference tags in new-search-api Repo INDEXES="mc_search" ESHOSTS="" #source from private config repo ESOPTS="{'timeout': 60, 'max_retries': 3}" # 'timeout' parameter is deprecated @@ -52,24 +52,35 @@ zzz() { } # Parse command-line options -while getopts :h:t optname; do - log "Option $optname set with value ${OPTARG}" - case $optname in - t) - IMAGE_TAG=${OPTARG} +while (( "$#" )); do + case "$1" in + -t|--tag) + if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then + IMAGE_TAG=$2 + shift 2 + else + echo "Error: Argument for $1 is missing" >&2 + exit 1 + fi ;; - h) + -h|--help) help - exit 2 + exit 0 ;; - \?) - echo "Invalid option: $1" + -*|--*=) # unsupported flags + echo "Error: Unsupported flag $1" >&2 help - exit 2 + exit 1 + ;; + *) # preserve positional arguments + PARAMS="$PARAMS $1" + shift ;; esac done +eval set -- "$PARAMS" + # Create a directory for private configuration PRIVATE_CONF_DIR="news_search_api_config" rm -rf "$PRIVATE_CONF_DIR" @@ -104,7 +115,6 @@ echo "Fetching $DOCKER_COMPOSE_FILE from $GH_REPO_NAME repo..." if ! curl -sSfL "$GH_REPO_PREFIX/$GH_REPO_NAME/raw/$IMAGE_TAG/$DOCKER_COMPOSE_FILE" -o "$INSTALL_DIR/$DOCKER_COMPOSE_FILE"; then echo "FATAL: Could not fetch $DOCKER_COMPOSE_FILE from config repo" exit 1 - fi # Deploy services using Docker Compose