bsition/run.sh

51 lines
1.1 KiB
Bash

#!/bin/sh
usage() {
cat <<EOF
usage: ${0##*/} [command]
-h Print this help message.
-a Run API on host 0.0.0.0:8000.
-i Install dependencies.
-d Run docker-compose up.
-c Configure databases.
-f Build and run frontend.
-t Run frontend in dev-mode.
EOF
exit 1
}
RUN=
while getopts "hadicft" OPTION; do
case $OPTION in
a) RUN=api ;;
d) RUN=docker ;;
i) RUN=install ;;
c) RUN=configure ;;
f) RUN=front ;;
t) RUN=test;;
*) usage ;;
esac
done
if [ "$RUN" = 'install' ]; then
poetry install
elif [ "$RUN" = 'api' ]; then
poetry run uvicorn bsition.api.main:app --host 0.0.0.0
elif [ "$RUN" = 'configure' ]; then
poetry run configure
elif [ "$RUN" = 'front' ]; then
cd bsition/frontend
npm install
npm run build
npm run start
elif [ "$RUN" = 'test' ]; then
cd bsition/frontend
npm run dev
else
[ ! -d data ] && mkdir data
[ ! -d data/postgres ] && mkdir data/postgres
[ ! -d data/mongo ] && mkdir data/mongo
[ ! -d data/elasticsearch ] && mkdir data/elasticsearch
docker-compose up
fi