-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·110 lines (91 loc) · 1.78 KB
/
make.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
#!/usr/bin/env bash
set -uex
rundir=${0%/*}
cd $rundir
NAME="sinopia"
PATH_APP="/${NAME}"
PORT=4873
RELEASE="sinopia-3f55fb4c0c6685e8b22796cce7b523bdbfb4019e"
TAG_PREFIX="deployable"
TAG_NAME="${NAME}"
TAG_TAG="latest"
ARG=${1:-}
if [ -z "$ARG" ]; then
set -- build "$@"
fi
die(){
echo "ERROR: $@"
echo "Exiting..."
exit 1
}
build(){
local tag=${1:-${TAG_TAG}}
[ -d "${RELEASE}" ] || download
docker build --build-arg DOCKER_BUILD_PROXY=http://10.8.8.8:3142 -t ${TAG_PREFIX}/${TAG_NAME}:${tag} .
}
download(){
wget -O ${RELEASE}.tar.gz.tmp https://github.com/rlidwka/sinopia/archive/3f55fb4c0c6685e8b22796cce7b523bdbfb4019e.tar.gz
mv ${RELEASE}.tar.gz.tmp $RELEASE.tar.gz
rm -rf ${RELEASE}
tar -xvf ${RELEASE}.tar.gz
}
rebuild(){
build
stop
start
}
run(){ start "$@"; }
start(){
docker run \
--detach \
--volume sinopia-storage:${PATH_APP}/storage:rw \
--publish ${PORT}:${PORT} \
--name ${NAME} \
--restart always \
${TAG_PREFIX}/${TAG_NAME}
}
stop(){
docker stop ${NAME} || echo stop failed
docker rm -f ${NAME} || echo remove failed
}
shell(){
docker exec -ti ${NAME} bash
}
logs(){
docker logs --tail 10 -f ${NAME}
}
publish(){
local tag=${1:-${TAG_TAG}}
docker push ${TAG_PREFIX}/${TAG_NAME}:${tag}
}
release(){
local release_date=$(date +%Y%m%d-%H%M%S)
[ -z "$(git status --porcelain)" ] || die "Git status not clean"
build ${release_date}
build latest
test_run
git push
git tag -f ${release_date}
publish $release_date
publish latest
git push -f --tags
}
test_start(){
echo "implement test_start"
}
test_exec(){
echo "implement test_exec"
}
test_stop(){
echo "implement test_stop"
}
test_clean(){
echo "implement test_clean"
}
test_run(){
test_start
test_exec
test_stop
test_clean
}
"$@"