Files
dd0c/products/build-push.sh
Max Mayfield 5a1e287ab6 Add console + marketing site to Docker Compose and build-push
- Console: nginx SPA on port 3010, image reg.dd0c.net/dd0c-console
- Marketing: nginx static on port 3011, image reg.dd0c.net/dd0c-marketing
- Dockerfiles + .dockerignore for both
- build-push.sh updated to include console + marketing targets
2026-03-03 00:36:48 +00:00

81 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# dd0c CI Build & Push to Local Registry
# Builds Docker images for all Node services and pushes to reg.dd0c.net
#
# Usage:
# ./build-push.sh # Build all services
# ./build-push.sh drift alert # Build specific services
set -euo pipefail
REGISTRY="${REGISTRY:-reg.dd0c.net}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
declare -A CONTEXTS=(
["dd0c-drift"]="02-iac-drift-detection/saas"
["dd0c-alert"]="03-alert-intelligence"
["dd0c-portal"]="04-lightweight-idp"
["dd0c-cost"]="05-aws-cost-anomaly"
["dd0c-run"]="06-runbook-automation/saas"
["dd0c-console"]="console"
["dd0c-marketing"]="marketing/site"
)
# If args provided, filter to those services
if [ $# -gt 0 ]; then
TARGETS=()
for arg in "$@"; do
key="dd0c-${arg}"
if [ -n "${CONTEXTS[$key]+x}" ]; then
TARGETS+=("$key")
else
echo -e "${RED}Unknown service: $arg${NC}" >&2
echo "Available: drift alert portal cost run console marketing" >&2
exit 1
fi
done
else
TARGETS=("dd0c-drift" "dd0c-alert" "dd0c-portal" "dd0c-cost" "dd0c-run" "dd0c-console" "dd0c-marketing")
fi
# Login to registry
echo "${REGISTRY_PASSWORD:-secret}" | docker login "$REGISTRY" --username dd0c --password-stdin 2>/dev/null || true
echo -e "${YELLOW}dd0c Build & Push — $(date -u '+%Y-%m-%d %H:%M UTC')${NC}"
echo -e "Registry: ${REGISTRY}\n"
FAILED=0
for img in "${TARGETS[@]}"; do
ctx="${CONTEXTS[$img]}"
tag="${REGISTRY}/${img}:latest"
echo -e "${YELLOW}▸ Building ${img}${NC}"
if docker build -t "$tag" --build-arg BUILD_SHA=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=$(date -u +%Y%m%dT%H%M%S) "$SCRIPT_DIR/$ctx" --no-cache; then
echo -e "${YELLOW} Pushing ${tag}${NC}"
if docker push "$tag"; then
echo -e " ${GREEN}${NC} ${img}"
else
echo -e " ${RED}${NC} Push failed: ${img}"
((FAILED++)) || true
fi
else
echo -e " ${RED}${NC} Build failed: ${img}"
((FAILED++)) || true
fi
echo ""
done
if [ "$FAILED" -eq 0 ]; then
echo -e "${GREEN}All images built and pushed.${NC}"
echo -e "Deploy: ${YELLOW}docker compose pull && docker compose up -d${NC}"
else
echo -e "${RED}${FAILED} service(s) failed.${NC}"
exit 1
fi