stacker.news/sndev

66 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-03-07 16:02:59 +00:00
#!/bin/sh
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 "$@"
}
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"
docker__compose up --build
}
sndev__stop() {
echo "Stopping application"
docker__compose down
}
sndev__delete() {
echo "Deleting application"
docker__compose down --volumes --remove-orphans
}
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" "$@"