-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild_deploy.sh
executable file
·46 lines (39 loc) · 1.53 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
#!/bin/bash
set -exv
IMAGE="quay.io/cloudservices/frontend-operator"
IMAGE_TAG=$(git rev-parse --short=7 HEAD)
SECURITY_COMPLIANCE_TAG="sc-$(date +%Y%m%d)-$(git rev-parse --short=7 HEAD)"
export BUILDER_NAME="builder-${JOB_NAME}-${BUILD_ID}"
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
DOCKER_CONF="$PWD/.docker"
mkdir -p "$DOCKER_CONF"
docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
# Check if the multiarchbuilder exists
if docker buildx ls | grep -q "multiarchbuilder"; then
docker buildx use multiarchbuilder
echo "Using multiarchbuilder for buildx"
# Multi-architecture build
if [[ $GIT_BRANCH == *"security-compliance"* ]]; then
docker buildx build --platform linux/amd64,linux/arm64 -t "${IMAGE}:${SECURITY_COMPLIANCE_TAG}" --push .
else
docker buildx build --platform linux/amd64,linux/arm64 -t "${IMAGE}:${IMAGE_TAG}" --push .
fi
else
echo "Falling back to standard build and push"
# Standard build and push
if [[ $GIT_BRANCH == *"security-compliance"* ]]; then
docker build -t "${IMAGE}:${SECURITY_COMPLIANCE_TAG}" .
docker push "${IMAGE}:${SECURITY_COMPLIANCE_TAG}"
else
docker build -t "${IMAGE}:${IMAGE_TAG}" .
docker push "${IMAGE}:${IMAGE_TAG}"
fi
fi