-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrun
More file actions
executable file
·123 lines (106 loc) · 3.35 KB
/
run
File metadata and controls
executable file
·123 lines (106 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env bash
#
# A script to make working with docker/compose to have
# less typing.
#
# For local development only.
COMPOSE="docker compose -f deployment/development/docker-compose.yml --project-directory . -p appbuilder-portal"
CI_COMPOSE="docker compose -f deployment/ci/docker-compose.yml --project-directory . -p appbuilder-portal-ci"
function runstuff {
# First arg
given_command=$1
# The rest of the args
arguments=${@:2}
case $given_command in
# docker compose proxy
dc) ${COMPOSE} $arguments;;
up:build) ${COMPOSE} up --build $arguments ;;
up) ${COMPOSE} up $arguments ;;
local)
runstuff dc up -d db adminer valkey stg-tunnel otel jaeger
;;
down)
${COMPOSE} down $arguments
;;
build) ${COMPOSE} build $arguments ;;
bash) ${COMPOSE} run --rm $arguments bash;;
restart) ${COMPOSE} stop $arguments && ${COMPOSE} start $arguments;;
bootstrap)
set -e
runstuff dc down --remove-orphans
runstuff local
runstuff db:migrate
runstuff dc down
set +e
;;
db:migrate)
npx prisma migrate dev --schema src/lib/prisma/schema.prisma
;;
db:reset)
npx prisma migrate reset --force --schema src/lib/prisma/schema.prisma
;;
db:show)
local adminer_url="http://localhost:18080/?pgsql=db&db=development&username=db-user"
echo "Opening Adminer database interface..."
if command -v open &> /dev/null; then
open "$adminer_url"
elif command -v xdg-open &> /dev/null; then
xdg-open "$adminer_url"
elif command -v start &> /dev/null; then
start "$adminer_url"
else
echo "Please open $adminer_url in your browser"
fi
;;
db:studio)
echo "Starting Prisma Studio..."
npm run diff-db && (set -a; source .env; set +a; npx prisma studio --schema src/lib/prisma/schema.prisma)
;;
##################
# Testing
ci:build)
${CI_COMPOSE} build
;;
ci)
${CI_COMPOSE} $arguments
;;
################
# Host-Machine Utils
# Don't name any folders bin, obj, tmp, dist, or node_modules
clean:all)
echo "Cleaning..."
shopt -s globstar
rm -rf **/out/ && \
rm -rf **/dist && \
rm -rf **/node_modules && \
rm -rf **/tmp
;;
*) print_help;;
esac
}
function print_help {
echo ""
echo "Available Commands:"
echo ""
echo "dc : short for docker compose"
echo "up:build : starts the docker compose services and builds images"
echo "up : starts the docker compose services"
echo "down : stops the docker compose services"
echo "local : starts external services in docker for local development"
echo ""
echo "bash : drop into a bash shell in a temporary docker compose service"
echo "restart : restart a specific docker compose service"
echo ""
echo "bootstrap : runs initial scripts for project setup"
echo "db:migrate : run prisma migrate dev command"
echo "db:reset : run prisma migrate reset command"
echo "db:show : open Adminer database interface in browser"
echo "db:studio : start Prisma Studio for database browsing"
echo ""
echo "clean:all : recursively removes out, dist, node_modules, and tmp directories"
}
if [ $1 ]; then
runstuff $*
else
print_help
fi