2024-03-07 16:02:59 +00:00
|
|
|
#!/bin/sh
|
2024-03-07 01:04:55 +00:00
|
|
|
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose() {
|
2024-03-09 02:07:43 +00:00
|
|
|
CURRENT_UID=$(id -u) CURRENT_GID=$(id -g) command docker compose --env-file .env.sndev "$@"
|
2024-03-08 19:11:15 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 01:04:55 +00:00
|
|
|
sndev__start() {
|
|
|
|
if [ ! -x "$(command -v docker-compose)" ]; then
|
|
|
|
echo "docker compose is not installed"
|
|
|
|
echo "installation instructions are here: https://docs.docker.com/desktop/"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -f .env.sndev ]; then
|
|
|
|
echo ".env.sndev does not exist."
|
|
|
|
echo "creating from .env.sample"
|
|
|
|
cp .env.sample .env.sndev
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose up --build
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sndev__stop() {
|
|
|
|
echo "Stopping application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose down
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sndev__delete() {
|
|
|
|
echo "Deleting application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose down --volumes --remove-orphans
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sndev__help() {
|
|
|
|
if [ $# -eq 3 ]; then
|
|
|
|
call "sndev__$1__$2__$3" "$@"
|
|
|
|
elif [ $# -eq 2 ]; then
|
|
|
|
call "sndev__$1__$2" "$@"
|
|
|
|
else
|
|
|
|
help="sndev manages a docker based stacker news development environment
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$ sndev [COMMAND]
|
|
|
|
|
|
|
|
COMMANDS
|
|
|
|
start start env
|
|
|
|
stop stop env
|
|
|
|
delete delete env
|
|
|
|
help display help for sndev
|
|
|
|
"
|
|
|
|
echo "$help"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
call() {
|
|
|
|
func=$1
|
|
|
|
if type "$func" 1>/dev/null 2>&1; then
|
|
|
|
shift
|
|
|
|
"$func" "$@" # invoke our named function w/ all remaining arguments
|
|
|
|
else
|
|
|
|
sndev__help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
call "sndev__$1" "$@"
|