#!/bin/bash
# Copyright ETSI 2018-2020
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

set -e
set -vx

# Docker login
if [ $# -eq 2 ]
then
    docker login --username $1 --password $2
fi

#check and build stfubuntu image
if [ -z `docker images -q stfubuntu` ]; then
  docker build --no-cache --tag stfubuntu:18.04 -f Dockerfile.stfubuntu --force-rm  . || exit 1
fi

TAG=etsiforge/titan-its-its

# Temporary: Remove TTF002 image
docker image rm --force $TAG

docker build --no-cache --tag $TAG --force-rm  . || ( echo "Docker build failed: $?"; exit 1 )

docker images
docker inspect $TAG || ( echo "Docker inspect failed: $?"; exit 1 )

docker push $TAG:latest

# That's all Floks
exit 0
