-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·100 lines (91 loc) · 2.24 KB
/
dev.sh
File metadata and controls
executable file
·100 lines (91 loc) · 2.24 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
#!/bin/bash
usage() {
cat <<'EOF'
Usage: ./dev.sh [options]
Options:
-b Skip frontend build
--release, -r Build backend in release mode
--stop Stop and remove containers
--status Show container status
-h, --help Show this help
EOF
}
# Parse command line arguments
SKIP_FRONTEND=false
RELEASE=false
STOP=false
STATUS=false
while [[ $# -gt 0 ]]; do
case "$1" in
-b)
SKIP_FRONTEND=true
shift
;;
--release|-r)
RELEASE=true
shift
;;
--stop)
STOP=true
shift
;;
--status)
STATUS=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
set -ex
if [[ "$STOP" = true ]]; then
docker compose -f docker-compose.yml -f docker-compose.dev.yml down
exit 0
fi
if [[ "$STATUS" = true ]]; then
docker compose -f docker-compose.yml -f docker-compose.dev.yml ps
exit 0
fi
# Build frontend unless -b flag is provided
if [[ "$SKIP_FRONTEND" = false ]]; then
export VITE_BASE_URL=/
if [[ "$RELEASE" = true ]]; then
npm --prefix site run build-only
else
npm --prefix site run build-only -- --mode development --minify false --sourcemap true
fi
fi
# Build backend based on OS
case "$(uname -s)" in
Linux)
if [[ "$RELEASE" = true ]]; then
export PKGLY_BINARY_PATH="./target/release/pkgly"
cargo build --release --features frontend
else
export PKGLY_BINARY_PATH="./target/debug/pkgly"
cargo build --features frontend
fi
;;
Darwin)
# Install zig and cargo-zigbuild if not already installed
# brew install zig
# cargo install cargo-zigbuild
# rustup target add aarch64-unknown-linux-gnu
ulimit -n 65536
if [[ "$RELEASE" = true ]]; then
export PKGLY_BINARY_PATH="./target/aarch64-unknown-linux-gnu/release/pkgly"
cargo zigbuild --release --target aarch64-unknown-linux-gnu --features frontend
else
export PKGLY_BINARY_PATH="./target/aarch64-unknown-linux-gnu/debug/pkgly"
cargo zigbuild --target aarch64-unknown-linux-gnu --features frontend
fi
;;
esac
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --force-recreate pkgly