forked from project-koku/koku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_deploy.sh
executable file
·49 lines (39 loc) · 1.58 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
44
45
46
47
48
49
#!/bin/bash
set -exv
export DOCKER_BUILDKIT=1
DOCKERFILE=${DOCKERFILE:="Dockerfile"}
IMAGE="quay.io/cloudservices/koku"
IMAGE_TAG=$(git rev-parse --short=7 HEAD)
GIT_COMMIT=$(git rev-parse --short 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
# on RHEL8 or anything else, use podman
# AUTH_CONF_DIR="$(pwd)/.podman"
# mkdir -p $AUTH_CONF_DIR
# export REGISTRY_AUTH_FILE="$AUTH_CONF_DIR/auth.json"
# podman login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
# podman login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
# podman build -t "${IMAGE}:${IMAGE_TAG}" .
# podman push "${IMAGE}:${IMAGE_TAG}"
# # Backward compatibility with CI/QA
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
# podman push "${IMAGE}:latest"
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:qa"
# podman push "${IMAGE}:qa"
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:clowder"
# podman push "${IMAGE}:clowder"
# on RHEL7, use docker
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" build --build-arg GIT_COMMIT=$GIT_COMMIT -t "${IMAGE}:${IMAGE_TAG}" .
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
docker --config="$DOCKER_CONF" tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
docker --config="$DOCKER_CONF" push "${IMAGE}:latest"
docker --config="$DOCKER_CONF" logout