-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·68 lines (53 loc) · 1.19 KB
/
run
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
#! /bin/bash
help() {
cat << UsageMessage
guesthub utilities
Usage: ./run [command]
Commands:
run
Starts the server in production mode
dev
Starts the server in development mode
reset_db
Resets the database
UsageMessage
}
updateHosts() {
# Define the entries to be added if missing
local entries=(
"127.0.0.1 guesthub.internal"
"127.0.0.1 api.guesthub.internal"
)
# Check and add each entry if it does not exist
for entry in "${entries[@]}"; do
if ! grep -q "$entry" /etc/hosts; then
echo "Adding $entry to /etc/hosts"
echo "$entry" | sudo tee -a /etc/hosts > /dev/null
else
echo "$entry already exists in /etc/hosts"
fi
done
}
run() {
docker compose up --build
}
build() {
docker compose build
}
dev() {
updateHosts
NODE_ENV=development docker compose up
}
reset_db() {
docker compose run --rm postgres dropdb -h postgres -U guesthub guesthub --force
docker compose run --rm postgres createdb -h postgres -U guesthub guesthub
}
clean_simulator() {
xcrun simctl erase all
}
if declare -F "$1" > /dev/null; then
$@
else
echo "Unknown command: $1"
help
fi