-
Notifications
You must be signed in to change notification settings - Fork 0
/
build everything & run.sh
43 lines (37 loc) · 1.8 KB
/
build everything & run.sh
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
# This script generates the front-end's SPA (Single Page Application),
# it consists of: 1 HTML page, 1 .js file, fonts & media files
## Option 1 - run server and use memory as the database
## Option 2 - run server and use a postgresql database. Make sure you have PostgreSQL service running and have ran the script to create the database and tables
## Option 3 - run in docker. Uses an internal postgresql which is created on startup
option=1
cd ./front-end
echo "🗣️ 🗣️ 🗣️ --- Installing npm packages --- 🗣️ 🗣️ 🗣️"
npm install
echo "🗣️ 🗣️ 🗣️ --- Building front-end --- 🗣️ 🗣️ 🗣️"
npm run prod
cd ..
# Copy website to the server resources and replace
yes | cp -rf xxx yyy ./front-end/dist/* ./back-end/src/main/resources/public/
cd ./back-end
## builds the .jar (the artifact is generated by this task provided by Spring)
echo "🗣️ 🗣️ 🗣️ --- Building spring artifact --- 🗣️ 🗣️ 🗣️"
bash ./gradlew bootJar
# & is used to run spring in background to allow running the rest of the script. This tells the shell not to wait for spring's process to complete
if [ "$option" = 1 ]; then
echo "Option 1"
java -jar ./build/libs/battleships-server-0.0.1-SNAPSHOT.jar --server-port=9000 &
elif [ "$option" = 2 ]; then
echo "Option 2"
java -jar ./build/libs/battleships-server-0.0.1-SNAPSHOT.jar postgres --server-port=9000 &
elif [ "$option" = 3 ]; then
echo "Option 3"
docker-compose -f docker-compose.yml -p "battleship-servers" up
else
echo "Not handled"
exit -1
fi
if [ "$option" -eq 1 ] || [ "$option" -eq 2 ]; then
echo "🗣️ 🗣️ 🗣️ --- Waiting a bit for spring to startup, then the page will open in your browser --- 🗣️ 🗣️ 🗣️"
sleep 5
sensible-browser "http://localhost:9000/"
fi