#!/bin/bash

# We need to remove already installed gems by Travis.
# Otherwise we may get openssl incompatibility error, because
# the image has different OpenSSL version, than Travis host system.
rm -rf ./vendor/bundle

if [[ "$TRAVIS_BRANCH" == "master" ]]; then
  CURRENT_TAG="latest"
else
  CURRENT_TAG=$TRAVIS_BRANCH 
fi

docker login -u "$DOCKER_HUB_USERNAME" -p "$DOCKER_HUB_PASSWORD"
docker build --build-arg master_key=$RAILS_MASTER_KEY -t symbiod/symbiod:$CURRENT_TAG -f Dockerfile .
docker push symbiod/symbiod:$CURRENT_TAG

