-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·70 lines (61 loc) · 1.54 KB
/
build
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
#!/bin/bash
run=false
pack=false
# Function to display script usage
function usage() {
echo "Usage: ./install.sh [--run | --pack]"
echo " --run Run the project."
echo " --pack Pack the project."
}
# Parse command-line arguments
while getopts ":r-:-:" opt; do
case $opt in
r)
run=true
;;
-)
case "${OPTARG}" in
run)
run=true
;;
pack)
pack=true
;;
*)
usage
exit 1
;;
esac
;;
*)
usage
exit 1
;;
esac
done
# Check for exclusivity
if [ "$run" = true ] && [ "$pack" = true ]; then
echo "Error: Cannot provide both --run and --pack options simultaneously."
usage
exit 1
fi
rm -r frontend/lab-control/dist
npm --prefix frontend/lab-control install
npm --prefix frontend/lab-control run build
# Build the frontend and copy files to deploy/ folder
yarn --cwd frontend add ./lab-control
yarn --cwd frontend install
yarn --cwd frontend run build
rm -rf deploy/frontend && cp -r frontend/dist deploy/frontend
# Build backend and copy files to deploy/ folder
# cc and openssl and openssl-devel (fedora) or libssl-dev (ubuntu) is needed for this step to work
cargo build --release --manifest-path=backend/Cargo.toml --target-dir=.tmp/
cp ./.tmp/release/backend deploy/backend
cp ./backend/src/database/init.sql deploy/init.sql
# Execute the last line if the "--run" option is provided
if [ "$run" = true ]; then
cd deploy && docker compose up
fi
if [ "$pack" = true ]; then
zip -r deploy.zip deploy
fi