Some checks failed
Deploy Environment Monitoring to Production Environment / deploy (push) Failing after 10s
Deploy workflows: - Integrate health-agent build (test) and image promotion (prod) into monitoring stack workflows - Add storagebox download of health-agent runtime (.env.monitoring.health-agent-runtime → health-agent/.env) and setup (.env.monitoring.health-agent-setup → health-agent/.env.setup) env files - Add "Run Uptime Kuma Setup" step: runs setup_uptime_kuma.py inside the built image only when uk_tokens.yml is missing, writes tokens to HEALTH_AGENT_CONFIG_GENERATED_DIR (/mnt/storagebox/monitoring/uk_generated) - Add health-agent/** and health-agent/deploy/prod.env path triggers to test and prod workflows respectively - Add HARBOR_CI_TOKEN login and HARBOR_PULL_TOKEN login before stack deploy in both workflows - Source health-agent/.env before docker stack deploy to expose HEALTH_AGENT_CONFIG_GENERATED_DIR Dockerfile: - Copy config/ and scripts/ into image so setup_uptime_kuma.py can run inside the container setup_uptime_kuma.py: - Load .env and .env.setup automatically via python-dotenv (no manual export needed) - Write uk_tokens.yml to config/generated/ (aligned with container volume mount) Health checks: - PATRONI_HOSTS and VAULT_HOSTS are now configurable via env vars (comma-separated host:port); no code change needed when node count changes - REDIS_SENTINEL_HOSTS now correctly parses host:port format; default updated to redis-sentinel:26379 - Fix NameError in check_patroni_cluster() caused by leftover node variable after loop refactor - Remove verify_ssl=False from Vault check; vault.iklim.co has a valid certificate Ops: - Add ops/build-and-push-health-agent.sh for manual bypass of CI pipeline - Add health-agent/deploy/prod.env template for prod image promotion manifest Project structure: - Move .env.example and .env.setup.example to health-agent/env-example/ (root .gitignore excludes health-agent/.env*) - Add root .gitignore: excludes uk_tokens.yml, __pycache__, .venv, and env files - Remove health-agent/.gitignore (superseded by root .gitignore)
67 lines
2.2 KiB
Bash
Executable File
67 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Builds the health-agent Docker image and pushes it to Harbor as a release candidate.
|
|
# Use this to bypass the CI pipeline for manual builds/hotfixes.
|
|
#
|
|
# Usage (run from Environment_Monitoring/ root):
|
|
# HARBOR_CI_TOKEN=<token> ./ops/build-and-push-health-agent.sh
|
|
#
|
|
# Optional env vars:
|
|
# HARBOR_REGISTRY (default: registry.tarla.io)
|
|
# HARBOR_PROJECT (default: iklimco)
|
|
# HARBOR_CI_USER (default: robot-ci-push-iklimco)
|
|
# TAG_SUFFIX (default: -rc)
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
HARBOR_REGISTRY="${HARBOR_REGISTRY:-registry.tarla.io}"
|
|
HARBOR_PROJECT="${HARBOR_PROJECT:-iklimco}"
|
|
HARBOR_CI_USER="${HARBOR_CI_USER:-robot-ci-push-iklimco}"
|
|
TAG_SUFFIX="${TAG_SUFFIX:--rc}"
|
|
|
|
log() { echo "[$(date +%H:%M:%S)] $*"; }
|
|
die() { echo "[$(date +%H:%M:%S)] ERROR: $*" >&2; exit 1; }
|
|
|
|
sep() {
|
|
local title="$*"
|
|
local line
|
|
line=$(printf '─%.0s' {1..70})
|
|
echo
|
|
echo "$line"
|
|
printf ' %s\n' "$title"
|
|
echo "$line"
|
|
}
|
|
|
|
[[ -z "${HARBOR_CI_TOKEN:-}" ]] && die "HARBOR_CI_TOKEN env var is required."
|
|
[[ -f "health-agent/pyproject.toml" ]] || die "health-agent/pyproject.toml not found — run from Environment_Monitoring/ root."
|
|
[[ -f "health-agent/Dockerfile" ]] || die "health-agent/Dockerfile not found."
|
|
|
|
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' health-agent/pyproject.toml)
|
|
[[ -n "$VERSION" ]] || die "Could not determine version from health-agent/pyproject.toml"
|
|
|
|
IMAGE="${HARBOR_REGISTRY}/${HARBOR_PROJECT}/health-agent:${VERSION}${TAG_SUFFIX}"
|
|
|
|
sep "health-agent → ${IMAGE}"
|
|
|
|
log "Logging in to ${HARBOR_REGISTRY} as ${HARBOR_CI_USER}"
|
|
echo "$HARBOR_CI_TOKEN" | docker login "$HARBOR_REGISTRY" -u "$HARBOR_CI_USER" --password-stdin
|
|
log "✔ Harbor login successful"
|
|
|
|
log "Building..."
|
|
docker build -t "$IMAGE" health-agent/
|
|
|
|
log "Pushing..."
|
|
docker push "$IMAGE"
|
|
docker pull -q "$IMAGE"
|
|
DIGEST=$(docker image inspect "$IMAGE" --format '{{index .RepoDigests 0}}')
|
|
|
|
log "✔ Pushed: ${IMAGE}"
|
|
|
|
sep "Promotion Manifest — write to health-agent/deploy/prod.env on prod-env branch"
|
|
echo
|
|
echo " SOURCE_IMAGE_DIGEST=${DIGEST}"
|
|
echo " PROD_IMAGE_TAG=${VERSION}"
|
|
echo
|