github.com/RedHatInsights/insights-content-service@v1.0.0/build_deploy.sh (about)

     1  #!/bin/bash
     2  # Copyright 2021 Red Hat, Inc
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #      http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -exv
    17  
    18  IMAGE="quay.io/cloudservices/ccx-insights-content-service"
    19  IMAGE_TAG=$(git rev-parse --short=7 HEAD)
    20  
    21  if [[ -z "$QUAY_USER" || -z "$QUAY_TOKEN" ]]; then
    22      echo "QUAY_USER and QUAY_TOKEN must be set"
    23      exit 1
    24  fi
    25  
    26  if [[ -z "$RH_REGISTRY_USER" || -z "$RH_REGISTRY_TOKEN" ]]; then
    27      echo "RH_REGISTRY_USER and RH_REGISTRY_TOKEN must be set"
    28      exit 1
    29  fi
    30  
    31  DOCKER_CONF="$PWD/.docker"
    32  mkdir -p "$DOCKER_CONF"
    33  docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
    34  docker --config="$DOCKER_CONF" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
    35  docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" .
    36  docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
    37  docker --config="$DOCKER_CONF" tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
    38  docker --config="$DOCKER_CONF" push "${IMAGE}:latest"