-
Notifications
You must be signed in to change notification settings - Fork 44
/
build-push.sh
101 lines (74 loc) · 2.58 KB
/
build-push.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
#!/bin/sh
# Copy this file out of project, then run build and push docker image
DOCKERHUB_NAME=""
VERSION="1.1.$(date +%Y%m%d%H%M)"
HOME=""
ROOTBULLETJOURNAL=""
LOGFILE=""
DOCKER_USERNAME=""
DOCKER_PASSWORD=""
GIT_PUBLIC_REPO="https://github.com/singerdmx/BulletJournal.git"
GIT_REPO=""
echo $DOCKERHUB_NAME
echo $VERSION
sync_git_repo() {
echo "sync git repo"
cd $HOME
rm -rf $ROOTBULLETJOURNAL
git clone $GIT_PUBLIC_REPO
}
genereate_frontend_version() {
echo "generate frontend version"
cd $ROOTBULLETJOURNAL/frontend/src/apis/
sed "s/BULLETJOURNAL_VERSION/$VERSION/g" versions-TEMPLATE > versions.ts
}
generate_docker_compose_yml() {
echo "generate_docker_compose_yml"
cd $ROOTBULLETJOURNAL/deployment
echo "# IMPORTANT: This file is auto-generated in build time; any change should be in docker-compose-TEMPLATE.yml" > docker-compose.yml
sed "s/BULLETJOURNAL_VERSION/$VERSION/g" docker-compose-TEMPLATE.yml >> docker-compose.yml
}
git_push() {
echo "####### git push ###########"
cd $ROOTBULLETJOURNAL/deployment
git add docker-compose.yml
git add $ROOTBULLETJOURNAL/frontend/src/apis/versions.ts
git commit -m "release $VERSION"
git remote set-url origin $GIT_REPO
git push
}
build_images() {
echo "####### build image ###########"
# frontend
cd $ROOTBULLETJOURNAL/frontend
/usr/local/bin/docker build -t $DOCKERHUB_NAME/bulletjournal-frontend:$VERSION .
# backend
cd $ROOTBULLETJOURNAL/backend
cp -R $ROOTBULLETJOURNAL/protobuf $ROOTBULLETJOURNAL/backend/
DOCKER_BUILDKIT=1 /usr/local/bin/docker build -t $DOCKERHUB_NAME/bulletjournal-backend:$VERSION .
# daemon
cd $ROOTBULLETJOURNAL/daemon
rm -rf ./proto_gen
mkdir -p ./proto_gen/github.com/singerdmx/BulletJournal
cp -R ../protobuf ./proto_gen/github.com/singerdmx/BulletJournal/
/usr/local/bin/docker build -t $DOCKERHUB_NAME/bulletjournal-daemon:$VERSION .
}
push_images() {
echo "######## push image #############"
whoami
pwd
/usr/local/bin/docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
/usr/local/bin/docker -v
/usr/local/bin/docker push $DOCKERHUB_NAME/bulletjournal-frontend:$VERSION
/usr/local/bin/docker push $DOCKERHUB_NAME/bulletjournal-backend:$VERSION
/usr/local/bin/docker push $DOCKERHUB_NAME/bulletjournal-daemon:$VERSION
echo "!!!!!!!! push image !!!!!!!!!!!!!"
}
echo "########## new ######"$VERSION
sync_git_repo
genereate_frontend_version
generate_docker_compose_yml
git_push
build_images
push_images
echo "########## end ######"$VERSION