#!/usr/bin/env bash

# In order to use this script you must first:
#
# 1: create an artifactory account and generate an API key if you haven't already
#   - https://confluence.zooxlabs.com/pages/viewpage.action?pageId=122994069#PackageManagement(Artifactory)-Setup
#
# 2: docker login fleetdash.docker.zooxlabs.com
#   - enter in your email as the username
#   - enter in your artifactory API key as the password

SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]:-${(%):-%x}}"))

(
cd $SCRIPT_DIR/..

VERSION_NUMBER="$1"

if [ -z $VERSION_NUMBER ]
  then
    echo
    echo "Usage:  ./push_image.sh VERSION"
    echo
    exit 0
fi

IMAGE_NAME="fleetdash.docker.zooxlabs.com/fleetdash:allocation_v$VERSION_NUMBER"
docker build . -t $IMAGE_NAME
docker push $IMAGE_NAME
)
