woj-ui-2/build_image.sh

27 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
COLOR_RED="\e[0;31m"
COLOR_GREEN="\e[0;32m"
COLOR_NONE="\e[0m"
function log_info() { echo -e "${COLOR_GREEN}$*${COLOR_NONE}" 1>&2; }
function log_error() { echo -e "${COLOR_RED}$*${COLOR_NONE}" 1>&2; }
DOCKER="${DOCKER:-podman}"
VERSION=$(jq -r .version < package.json)
IMAGE_PREFIX=${IMAGE_PREFIX:-"git.0x7f.app/woj"}
if [ -f ".env.sentry-build-plugin" ]; then source .env.sentry-build-plugin; fi
if [ -z "$SENTRY_AUTH_TOKEN" ]; then log_error "SENTRY_AUTH_TOKEN not found!"; exit 1; fi
log_info "=== Configuration ==="
log_info "DOCKER: ${DOCKER}"
log_info "IMAGE: ${IMAGE_PREFIX}/woj-ui:${VERSION}"
log_info "SENTRY_AUTH_TOKEN: $(echo "$SENTRY_AUTH_TOKEN" | head -c 12)***"
log_info "=== Build ==="
$DOCKER build -t "${IMAGE_PREFIX}/woj-ui:${VERSION}" --build-arg "SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}" . || { log_error "Build image failed!"; exit 1; }
log_info "=== Push ==="
$DOCKER push "${IMAGE_PREFIX}/woj-ui:${VERSION}" || { log_error "Push image failed"; exit 1; }