forked from RedHatInsights/clowder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_deploy.sh
executable file
·43 lines (32 loc) · 1.38 KB
/
build_deploy.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
#!/bin/bash
set -exv
IMAGE="quay.io/cloudservices/clowder"
IMAGE_TAG=$(git rev-parse --short=7 HEAD)
if [[ -z "$QUAY_USER" || -z "$QUAY_TOKEN" ]]; then
echo "QUAY_USER and QUAY_TOKEN must be set"
exit 1
fi
if [[ -z "$RH_REGISTRY_USER" || -z "$RH_REGISTRY_TOKEN" ]]; then
echo "RH_REGISTRY_USER and RH_REGISTRY_TOKEN must be set"
exit 1
fi
BASE_TAG=`cat go.mod go.sum Dockerfile.base | sha256sum | head -c 7`
BASE_IMG=quay.io/cloudservices/clowder-base:$BASE_TAG
DOCKER_CONF="$PWD/.docker"
mkdir -p "$DOCKER_CONF"
docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker --config="$DOCKER_CONF" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
RESPONSE=$( \
curl -Ls -H "Authorization: Bearer $QUAY_API_TOKEN" \
"https://quay.io/api/v1/repository/cloudservices/clowder-base/tag/?specificTag=$BASE_TAG" \
)
echo "received HTTP response: $RESPONSE"
# find all non-expired tags
VALID_TAGS_LENGTH=$(echo $RESPONSE | jq '[ .tags[] | select(.end_ts == null) ] | length')
if [[ "$VALID_TAGS_LENGTH" -eq 0 ]]; then
docker --config="$DOCKER_CONF" build -f Dockerfile.base . -t "$BASE_IMG"
docker --config="$DOCKER_CONF" push "$BASE_IMG"
fi
make update-version
docker --config="$DOCKER_CONF" build --build-arg BASE_IMAGE="$BASE_IMG" -t "${IMAGE}:${IMAGE_TAG}" .
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"