#!/bin/bash
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" || exit

docker build API_Server/ -f work_image -t work_image

echo
echo "[BUILD] Done! Entering docker container"
echo

docker run -it \
	--mount type=bind,source="$(pwd)"/API_Server/app.py,target=/app.py \
	--mount type=bind,source="$(pwd)"/API_Server/gunicorn-cfg.py,target=/gunicorn-cfg.py \
	--mount type=bind,source="$(pwd)"/API_Server/Background,target=/Background \
	--mount type=bind,source="$(pwd)"/API_Server/Blueprints,target=/Blueprints \
	--mount type=bind,source="$(pwd)"/API_Server/Models,target=/Models \
	--mount type=bind,source="$(pwd)"/API_Server/Matching,target=/Matching \
	--mount type=bind,source="$(pwd)"/API_Server/Rest,target=/Rest \
	--mount type=bind,source="$(pwd)"/API_Server/Notify,target=/Notify \
	--mount type=bind,source="$(pwd)"/API_Server/StaticData,target=/StaticData \
	--mount type=bind,source="$(pwd)"/API_Server/migrations,target=/migrations \
	--net=host \
	work_image fish

echo
echo "[CLEANUP] removing unused docker resources"
docker system prune -f

exit
