#!/bin/sh

profile_name=test
if [ "$1" != "" ]; then
    profile_name=$1
fi

cd ..
git pull
mvn clean package -Dmaven.test.skip=true -P ${profile_name}
cd docker
./copy.sh

sudo docker stop wfc-gateway
sudo docker rm wfc-gateway
sudo docker rmi docker_wfc-gateway

sudo docker stop wfc-auth
sudo docker rm wfc-auth
sudo docker rmi docker_wfc-auth

sudo docker stop wfc-modules-system
sudo docker rm wfc-modules-system
sudo docker rmi docker_wfc-modules-system

sudo docker stop wfc-modules-user
sudo docker rm wfc-modules-user
sudo docker rmi docker_wfc-modules-user

sudo docker stop wfc-modules-job
sudo docker rm wfc-modules-job
sudo docker rmi docker_wfc-modules-job

sudo docker stop wfc-modules-file
sudo docker rm wfc-modules-file
sudo docker rmi docker_wfc-modules-file

sudo docker stop wfc-modules-gen
sudo docker rm wfc-modules-gen
sudo docker rmi docker_wfc-modules-gen

sudo ./deploy.sh backend
