forked from RedHatInsights/vuln4shift-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_deploy.sh
executable file
·30 lines (23 loc) · 915 Bytes
/
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
#!/bin/bash
set -exv
IMAGE="quay.io/cloudservices/vuln4shift-backend-app"
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
AUTH_CONF_DIR="$(pwd)/.podman"
mkdir -p $AUTH_CONF_DIR
export REGISTRY_AUTH_FILE="$AUTH_CONF_DIR/auth.json"
# Last tag if present
VERSION="$(git describe --tags --abbrev=0 || echo dev)"
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 --build-arg="VERSION=$VERSION" --pull=true -f Dockerfile -t "${IMAGE}:${IMAGE_TAG}" .
podman push "${IMAGE}:${IMAGE_TAG}"
podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
podman push "${IMAGE}:latest"