#!/usr/bin/env bash # ───────────────────────────────────────────────────────────────────────────── # Build + push the sitomat control-plane images to a PRIVATE REGISTRY. # # Run from anywhere in the repo, on a host WITH the source. The DEPLOY host does # not need this script (nor the source) — it only pulls. # # Requires a prior `docker login `. # # Env (usually from docker/.env — loaded automatically when present): # SITOMAT_IMAGE_REGISTRY e.g. registry.contoh.go.id/sitomat # SITOMAT_IMAGE_TAG e.g. 1.0.0 (or demo / prod / latest) # NEXT_PUBLIC_DEMO_LOGIN true|false — BAKED into the web image # NEXT_PUBLIC_KEYCLOAK_ENABLED true|false — BAKED into the web image # WEB_API_BASE_URL empty = same-origin (recommended); set an # absolute origin only for two-domain setups # # Examples: # SITOMAT_IMAGE_REGISTRY=registry.contoh.go.id/sitomat SITOMAT_IMAGE_TAG=1.0.0 \ # NEXT_PUBLIC_DEMO_LOGIN=false docker/build-push.sh # # # a DEMO image (demo login ON) — separate tag, because the flag is baked: # SITOMAT_IMAGE_REGISTRY=registry.contoh.go.id/sitomat SITOMAT_IMAGE_TAG=demo \ # NEXT_PUBLIC_DEMO_LOGIN=true docker/build-push.sh # ───────────────────────────────────────────────────────────────────────────── set -euo pipefail cd "$(dirname "$0")/.." ENV_FILE="docker/.env" ENV_FLAG="" if [ -f "$ENV_FILE" ]; then ENV_FLAG="--env-file $ENV_FILE" fi : "${SITOMAT_IMAGE_REGISTRY:?set SITOMAT_IMAGE_REGISTRY, e.g. registry.contoh.go.id/sitomat}" : "${SITOMAT_IMAGE_TAG:?set SITOMAT_IMAGE_TAG, e.g. 1.0.0}" FILES="-f docker-compose.control-plane.yml -f docker-compose.build.yml" echo "==> building api + web (tag ${SITOMAT_IMAGE_TAG})" # shellcheck disable=SC2086 docker compose $ENV_FLAG $FILES build api web echo "==> pushing api + web to ${SITOMAT_IMAGE_REGISTRY}" # shellcheck disable=SC2086 docker compose $ENV_FLAG $FILES push api web echo echo "==> pushed:" echo " ${SITOMAT_IMAGE_REGISTRY}/api:${SITOMAT_IMAGE_TAG}" echo " ${SITOMAT_IMAGE_REGISTRY}/web:${SITOMAT_IMAGE_TAG}" echo echo "On a deploy host, set the SAME SITOMAT_IMAGE_REGISTRY/TAG in docker/.env," echo "then: docker compose --env-file docker/.env -f docker-compose.control-plane.yml pull && ... up -d"