-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·120 lines (111 loc) · 3.33 KB
/
build.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# sed -i 's/\r//' build.sh
# chmod u+x build.sh
# BUILD is where docker-compose build
BUILD=build
# SERVICES is all service
SERVICES=(
microservices-account
microservices-configuration
microservices-gateway
microservices-registry
microservices-uno
microservices-home
)
SOURCE_CONFIGS="$PWD/microservices-configuration/src/main/resources/configurations/*"
# WSL_IP=$(ifconfig eth0 | grep -w inet | awk '{print $2}')
init() {
echo "create .env"
echo "# HOST_CONFIG_LOCATION which is where your configurations files located" >.env
sed -i "\$a HOST_CONFIG_LOCATION=$PWD/build/configurations" .env
sed -i '$a TZ=Asia/Shanghai' .env
sed -i '$a REGION=wsl' .env
sed -i '$a VERSION=0.0.0' .env
sed -i '$a REGISTRY_URL=http://wsl2.sbx0.cn:8761/eureka/' .env
sed -i '$a SECURITY_NAME=sbx0' .env
sed -i '$a SECURITY_PASSWORD=test' .env
sed -i '$a CONFIG_URL=http://wsl2.sbx0.cn:8888' .env
sed -i '$a CONFIG_LOCATION=/home/sbx0/configurations' .env
sed -i '$a REDIS_HOST=wsl2.sbx0.cn' .env
sed -i '$a REDIS_PORT=6379' .env
sed -i '$a REDIS_PASSWORD=test' .env
sed -i '$a DB_URL=jdbc:mysql://wsl2.sbx0.cn:3306/assembler?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true' .env
sed -i '$a DB_USERNAME=root' .env
sed -i '$a DB_PASSWORD=test' .env
sed -i '$a # REGISTRY' .env
sed -i '$a REGISTRY_PORT=8761' .env
sed -i '$a REGISTRY_PROFILES=dev' .env
sed -i '$a # CONFIGURATION' .env
sed -i '$a CONFIGURATION_PORT=8888' .env
sed -i '$a CONFIGURATION_PROFILES=native' .env
sed -i '$a # GATEWAY' .env
sed -i '$a GATEWAY_PORT=8080' .env
sed -i '$a GATEWAY_PROFILES=dev' .env
sed -i '$a NEXT_URL=http://win.sbx0.cn:3000' .env
sed -i '$a # ACCOUNT' .env
sed -i '$a ACCOUNT_PORT=0' .env
sed -i '$a ACCOUNT_PROFILES=dev' .env
sed -i '$a # UNO' .env
sed -i '$a UNO_PORT=0' .env
sed -i '$a UNO_PROFILES=dev' .env
sed -i '$a # HOME' .env
sed -i '$a HOME_PORT=0' .env
sed -i '$a HOME_PROFILES=dev' .env
sed -i '$a IP_ADDRESS=wsl2.sbx0.cn' .env
# sed -i "\$a CONFIG_LOCATION=${PWD}/${BUILD}/configurations" .env
# echo "config environment"
# sed -i "\$a MICROSERVICES_DIR=${PWD}" /etc/environment
# source /etc/environment
echo "init finished"
mkdir "$PWD/$BUILD"
mkdir "$PWD/$BUILD/configurations"
}
build() {
echo "maven building"
mvn -T 1C -DskipTests clean install
echo "build finished"
}
copy() {
for SERVICE in "${SERVICES[@]}"; do
rm -rf "${PWD:?}/${BUILD:?}/${SERVICE:?}"
mkdir "${PWD:?}/${BUILD:?}/${SERVICE:?}"
cp -f ${PWD:?}"/"${SERVICE:?}"/"target/*.jar "${PWD:?}/${BUILD:?}/${SERVICE:?}"
cp -f ${PWD:?}"/"${SERVICE:?}"/"*Dockerfile "${PWD:?}/${BUILD:?}/${SERVICE:?}"
echo "${SERVICE} files copy"
done
cp -f $SOURCE_CONFIGS "${PWD:?}/${BUILD:?}/configurations"
echo "configurations files copy"
cp -f $PWD/docker-compose*.yml "${PWD:?}/${BUILD:?}"
echo "docker-compose files copy"
cp -f $PWD/compose.sh "${PWD:?}/${BUILD:?}"
echo "compose.sh copy"
cp -f $PWD/.env "${PWD:?}/${BUILD:?}"
echo ".env copy"
echo "copy finished"
}
copy-up() {
copy
cd build || exit
./compose.sh build-and-up "$1" "$2"
}
log() {
cd build
./compose.sh log "$1"
}
case "$1" in
"init" | "i")
init
;;
"build" | "b")
build
;;
"copy" | "c")
copy
;;
"log" | "l")
log "$2"
;;
*)
copy-up "$1" "$2"
;;
esac