44 lines
893 B
Bash
Executable File
44 lines
893 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
function wait_service {
|
|
echo -e "\n-> Waiting for service $1, $2...\n"
|
|
while ! nc -z $1 $2; do
|
|
exec sleep 1
|
|
done
|
|
}
|
|
|
|
function install_general_dependencies {
|
|
echo -e "\n-> Installing general dependencies...\n"
|
|
go get -u github.com/cosmtrek/air
|
|
go install github.com/cosmtrek/air
|
|
go install github.com/go-delve/delve/cmd/dlv@latest
|
|
|
|
}
|
|
|
|
function install_app_dependencies {
|
|
echo -e "\n-> Installing app dependencies...\n"
|
|
cd /code
|
|
go mod tidy
|
|
}
|
|
|
|
case $1 in
|
|
run-server)
|
|
wait_service $DATABASE_HOST $DATABASE_PORT
|
|
install_general_dependencies
|
|
install_app_dependencies
|
|
echo -e "\n-> Run server...\n"
|
|
exec air
|
|
;;
|
|
run-tests)
|
|
install_app_dependencies
|
|
echo -e "\n-> Run tests...\n"
|
|
exec gotest -v ./...
|
|
;;
|
|
*)
|
|
exec "$@"
|
|
;;
|
|
esac
|
|
|