-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker.sh
executable file
·61 lines (58 loc) · 2.17 KB
/
docker.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
#!/bin/sh -e
#
# Author:: Lance Albertson <[email protected]>
# Copyright:: Copyright 2020, Cinc Project
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cat << EOF > /tmp/docker-token
$DOCKER_TOKEN
EOF
cat /tmp/docker-token | docker login --username $DOCKER_USERNAME --password-stdin
rm -rf /tmp/docker-token
cd inspec
VERSION="$(cat VERSION)"
MAJ="$(cat VERSION | cut -d '.' -f 1)"
MIN="$(cat VERSION | cut -d '.' -f 2)"
# Point directly to OSUOSL master mirror
URL="http://ftp-osl.osuosl.org/pub/cinc/files/${CHANNEL}/cinc-auditor/${VERSION}/el/8/cinc-auditor-${VERSION}-1.el8.x86_64.rpm"
COUNT=0
SLEEP=10
MAX_COUNT=300
# The Dockerfile pulls a built rpm from a URL instead of using the source. The
# following ensures that we wait until the RPM has been deployed onto our
# mirrors. By default, it will try the URL, wait 10 seconds if it fails and keep
# doing that for 5 minutes. If nothing happens within those five minutes, then
# something is obviously wrong and exits with 1.
while [ ${COUNT} -le ${MAX_COUNT} ] ; do
if [ ${COUNT} -ge ${MAX_COUNT} ] ; then
echo "Exceeded ${MAX_COUNT} seconds, giving up..."
exit 1
fi
curl --output /dev/null --silent --head --fail "$URL"
STATUS=$?
if [ "${STATUS}" -eq 0 ] ; then
echo "${URL} ready!"
break
else
echo "${URL} is not ready, waiting for ${SLEEP} seconds... (${COUNT}/${MAX_COUNT})"
sleep ${SLEEP}
COUNT=`expr ${COUNT} + ${SLEEP}`
fi
done
set -x
docker build --pull --no-cache -t cincproject/auditor:${VERSION} .
docker tag cincproject/auditor:${VERSION} cincproject/auditor:latest
docker push cincproject/auditor:${VERSION}
docker push cincproject/auditor:latest
rm -rf ${HOME}/.docker