|
1 |
| -set -ex |
| 1 | +set -e |
| 2 | +set -o pipefail |
2 | 3 |
|
3 |
| -# find latest tag from github |
4 |
| -tag=$(curl https://api.github.com/repos/pritunl/pritunl/tags | jq -r '.[0].name') |
| 4 | +DOCKER_ARGS="--squash" |
| 5 | +DEBUG=${DEBUG:0} |
| 6 | + |
| 7 | +if [ "${DEBUG}" != "1" ]; then |
| 8 | + DOCKER_ARGS="$DOCKER_ARGS --quiet" |
| 9 | +fi |
| 10 | + |
| 11 | +if [ "${DEBUG}" == "1" ]; then |
| 12 | + set -x |
| 13 | +fi |
5 | 14 |
|
6 | 15 | # ensure checkout directory exist
|
7 | 16 | if [ ! -d "/tmp/docker-pritunl" ]; then
|
8 | 17 | git clone https://github.com/jippi/docker-pritunl.git /tmp/docker-pritunl
|
9 | 18 | fi
|
10 | 19 |
|
11 | 20 | # change work dir
|
12 |
| -cd /tmp/docker-pritunl/ |
| 21 | +# cd /tmp/docker-pritunl/ |
13 | 22 |
|
14 | 23 | # update repo
|
15 |
| -git pull |
| 24 | +# git pull |
| 25 | + |
| 26 | +# docker tags |
| 27 | +docker_tags=$(curl -s https://hub.docker.com/v2/repositories/jippi/pritunl/tags/ | jq -r '.results[].name') |
| 28 | +docker_tags="" |
| 29 | + |
| 30 | +function has_tag() { |
| 31 | + check=$(echo "${docker_tags}" | grep "^$1$") |
| 32 | + if [ "${check}" == "" ]; then |
| 33 | + return 1 |
| 34 | + else |
| 35 | + return 0 |
| 36 | + fi |
| 37 | +} |
| 38 | + |
| 39 | +# find latest tag from github |
| 40 | +github_tags=$(curl -s https://api.github.com/repos/pritunl/pritunl/tags | jq -r '.[].name') |
| 41 | +first=1 |
| 42 | +for tag in $github_tags; do |
| 43 | + echo "[${tag}] Processing" |
| 44 | + |
| 45 | + # build with mongo (default container) |
| 46 | + if ! has_tag "${tag}"; then |
| 47 | + echo "[${tag}] Building" |
| 48 | + docker build $DOCKER_ARGS -t "jippi/pritunl:${tag}-minimal" --build-arg PRITUNL_VERSION="${tag}" . |
| 49 | + |
| 50 | + echo "[${tag}] Pushing" |
| 51 | + docker push "jippi/pritunl:${tag}" |
| 52 | + |
| 53 | + if [ $first -eq 1 ]; then |
| 54 | + echo "[${tag}] Tagging as latest" |
| 55 | + docker tag "jippi/pritunl:${tag}" "jippi/pritunl:latest" |
| 56 | + |
| 57 | + echo "[${tag}] Pushing as latest" |
| 58 | + docker push "jippi/pritunl:latest" |
| 59 | + fi |
| 60 | + |
| 61 | + echo "[${tag}] Done" |
| 62 | + else |
| 63 | + echo "[${tag}] Already build" |
| 64 | + fi |
| 65 | + |
| 66 | + # build without mongo (special tag) |
| 67 | + if ! has_tag "${tag}-minimal"; then |
| 68 | + echo "[${tag}-minimal] Building" |
| 69 | + docker build $DOCKER_ARGS -t "jippi/pritunl:${tag}" --build-arg PRITUNL_VERSION="${tag}" --build-arg MONGODB_VERSION=no . |
| 70 | + |
| 71 | + echo "[${tag}-minimal] Pushing" |
| 72 | + docker push "jippi/pritunl:${tag}-minimal" |
16 | 73 |
|
17 |
| -# build without mongo (default container) |
18 |
| -docker build -t "jippi/pritunl:${tag}" --build-arg PRITUNL_VERSION="${tag}*" --build-arg MONGODB_VERSION=no . |
19 |
| -docker push "jippi/pritunl:${tag}" |
| 74 | + if [ $first -eq 1 ]; then |
| 75 | + echo "[${tag}-minimal] Tagging as latest-minimal" |
| 76 | + docker tag "jippi/pritunl:${tag}-minimal" "jippi/pritunl:latest-minimal" |
20 | 77 |
|
21 |
| -docker tag "jippi/pritunl:${tag}" "jippi/pritunl:latest" |
22 |
| -docker push "jippi/pritunl:latest" |
| 78 | + echo "[${tag}-minimal] Pushing as latest-minimal" |
| 79 | + docker push "jippi/pritunl:latest-minimal" |
| 80 | + fi |
23 | 81 |
|
24 |
| -# build with mongo (special tag) |
25 |
| -docker build -t "jippi/pritunl:${tag}-mongo" --build-arg PRITUNL_VERSION="${tag}*" . |
26 |
| -docker push "jippi/pritunl:${tag}-mongo" |
| 82 | + echo "[${tag}-minimal] Done" |
| 83 | + else |
| 84 | + echo "[${tag}-minimal] Already build" |
| 85 | + fi |
27 | 86 |
|
28 |
| -docker tag "jippi/pritunl:${tag}" "jippi/pritunl:latest-mongo" |
29 |
| -docker push "jippi/pritunl:latest-mongo" |
| 87 | + first=0 |
| 88 | +done |
0 commit comments