-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
47 lines (37 loc) · 1.06 KB
/
start.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
44
45
46
47
#!/bin/bash
# Get project version
PROJECT_VERSION=$(grep -Po "version = '\K[^']+" build.gradle)
echo "$PROJECT_VERSION"
# Pull new changes
echo "Pulling updated repository"
git pull
# Checkout to needed git branch
echo "Checkout for branch"
git checkout "$1"
# Give permissions to gradlew
chmod +x gradlew
# Prepare JAR
echo "Build Java app"
./gradlew clean
./gradlew build -x test
#copy not secret configuration to .env
cat .env.config> ./build/.env
# Rename java build
mv build/libs/CompanyBot-"$PROJECT_VERSION".jar build/libs/app.jar
rc=$?
# if gradle failed, then we will not deploy new version.
if [ $rc -ne 0 ] ; then
echo Could not perform gradle clean build, exit code [$rc]; exit $rc
fi
echo "Build successful"
# Add env vars to .env config file
echo "$2" >> ./build/.env
echo "$3" >> ./build/.env
#create volume if not exists
sudo mkdir -p /var/docker-volumes/cbot-pg
# ensure start docker-compose stopped
docker-compose --env-file ./build/.env stop
#Go
echo "Starting docker compose"
docker-compose --env-file ./build/.env up --build -d
echo "Services stared, enjoy"