#! /bin/bash

set -ex

# Don't use --squash option in order to squash docker image into single layer, it does not take any affect 
# using within Circle CI, it takes the same time to pull and extract docker image and don't give any benefits
# by the way using option also increase the build time and increase time to push into docker registry

# docker_image="skinholdings/drakemall:console-latest"
# docker build --squash -f .docker/Dockerfile.console -t $docker_image .
# docker push $docker_image

export COMPOSE_FILE=$PWD/docker-compose.console.yml

echo "  Step ==> 1"
echo "  Validate docker compose files"
docker-compose config -q

echo "  Step ==> 2"
echo "  Build console docker image"
docker-compose build console

# docker tag "$(docker-compose config | yq -r .services.console.image)" skinholdings/drakemall:console-latest

# does not work properly user input
# read -p 'Would you like push to docker registry (yes/no)? ' approve_push

# if [ "$approve_push" == "yes" ]; then
#   docker push skinholdings/drakemall:console-latest
# fi
