#!/bin/bash export COMPOSE_PROJECT_NAME=laurelinapi function confirm() { echo -n "$@ [y/N]: " read -e answer for response in y Y do if [ "_$answer" == "_$response" ] then return 0 fi done # default to no return 1 } function dockerlaunch() { confirm reset containers? && docker compose down confirm reset database? && docker volume rm laurelinapi_apidb_data confirm rebuild api? && docker compose build confirm launch? && docker compose up } function nixenv() { nix develop } function nixsetup() { export PGDATA=/tmp/laurelinpgdata initdb pg_ctl -o "-k /tmp" start createdb -h /tmp laurelinapi export GIN_MODE=release # or "debug" for debug logs export LAURELINAPI_JWT_SECRET=XpNYdG7vgvgPPuezrtZqt4CJIUuxNP7c export GORM_DB_STRING="host=localhost dbname=laurelinapi port=5432 sslmode=disable" go run main.go } if confirm nix? then if confirm "in devshell?" then nixsetup else nixenv fi else dockerlaunch fi