#!/bin/bash
if [ "$1" == "" ] ; then
    printf "\nDocker image-a version param missing"
    printf "\n\nSyntax:\n\n    deploy-swarm.sh 1.0.0\n\n"
    exit 1
fi

printf "\nBUILD START ...\n\n"

IMAGE_VERSION=$1
COMPOSE_FILE="docker-compose-swarm.yml"

echo "Deploying with image version: $IMAGE_VERSION"

# Pass IMAGE_VERSION env var for compose variable substitution
IMAGE_VERSION="$IMAGE_VERSION" docker stack deploy \
    -c "$COMPOSE_FILE" \
    utility-bills-tracker