#!/bin/bash
#
#	Build the Docker Container
#
dir=`dirname $0`
cd $dir

# Check we have a RSA key
#if [ ! -r ${HOME}/.ssh/id_rsa.pub ] ; then
#	echo ""
#	echo "ERROR:"
#	echo "  Cannot proceed without an ${HOME}/.ssh/id_rsa.pub"
#	echo "  See http://lmgtfy.com/?q=creating+rsa+keys"
#	echo ""
#	exit 1
#fi


# Don't care if these fail due to container-not-found
#echo ""
#echo "$ docker kill {{&CONTAINER_NAME}}-container"
#docker kill {{&CONTAINER_NAME}}-container
echo ""
echo "$ docker rm -f {{&CONTAINER_NAME}}-container"
docker rm -f {{&CONTAINER_NAME}}-container
echo ""
echo "$ docker rmi -f {{&CONTAINER_NAME}}-image"
docker rmi {{&CONTAINER_NAME}}-image


# Build the new image
echo ""
echo "$ docker build -q -t {{&CONTAINER_NAME}}-image ."
docker build -t {{&CONTAINER_NAME}}-image .
rv=$?


# Anything else?


#Finish up
exit ${rv}