-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbase.bash
executable file
·71 lines (54 loc) · 1.84 KB
/
base.bash
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
#!/usr/bin/env bash
# Copyright (C) 2017 Swift Navigation Inc.
# Contact: Swift Navigation <[email protected]>
#
# This source is subject to the license found in the file 'LICENSE' which must
# be be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
set -euo pipefail
IFS=$'\n\t'
[[ -z "${DEBUG:-}" ]] || set -x
[[ -n "${LOCAL_BUILD:-}" ]] || \
[[ -n "${DOCKER_USER:-}" ]] || {
echo "DOCKER_USER: must not be empty"
exit 1
}
[[ -n "${LOCAL_BUILD:-}" ]] || \
[[ -n "${DOCKER_PASS:-}" ]] || {
echo "DOCKER_PASS: must not be empty"
exit 1
}
DOCKER_NAMETAG=$(cat docker_nametag)
query_build_pushed() {
local repo_tag=$1; shift
repo_tag=${repo_tag##*:}
TOKEN=$(curl -s -H "Content-Type: application/json" \
-X POST -d '{"username": "'"${DOCKER_USER}"'", "password": "'"${DOCKER_PASS}"'"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)
ORG=swiftnav
REPO=arm-llvm-obf
curl -s -H "Authorization: JWT ${TOKEN}" \
https://hub.docker.com/v2/repositories/${ORG}/${REPO}/tags/?page_size=100 \
| jq '.results | .[] | .name' \
| grep "$repo_tag"
}
if [[ -z "${LOCAL_BUILD:-}" ]] && \
[[ -n "$(query_build_pushed "$DOCKER_NAMETAG")" ]]; then
echo "Build already pushed, exiting..."
exit 0
fi
docker build \
--force-rm --no-cache \
-f Dockerfile.base -t "$DOCKER_NAMETAG" .
docker build \
--force-rm --no-cache \
--build-arg "DOCKER_NAMETAG=$DOCKER_NAMETAG" \
-f Dockerfile.vanilla -t "$DOCKER_NAMETAG-vanilla" .
docker build \
--force-rm --no-cache \
--build-arg "DOCKER_NAMETAG=$DOCKER_NAMETAG" \
-f Dockerfile.obfuscator -t "$DOCKER_NAMETAG-obfuscator" .
./push.bash