Files
ai-tax-agent/scripts/remote-build-base-ml.sh
harkon b324ff09ef
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
Initial commit
2025-10-11 08:41:36 +01:00

111 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Remote Build Script for base-ml Image
# This script builds the base-ml image on the remote production server
# to avoid pushing 1.2GB+ over the network from local machine
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE} $1${NC}"
}
log_success() {
echo -e "${GREEN}$1${NC}"
}
log_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
log_error() {
echo -e "${RED}$1${NC}"
}
# Configuration
REMOTE_HOST="${1:-deploy@141.136.35.199}"
REMOTE_DIR="${2:-/home/deploy/ai-tax-agent}"
REGISTRY="${3:-gitea.harkon.co.uk}"
VERSION="${4:-v1.0.1}"
OWNER="${5:-harkon}"
log_info "Remote Build Configuration"
echo " Remote Host: $REMOTE_HOST"
echo " Remote Directory: $REMOTE_DIR"
echo " Registry: $REGISTRY"
echo " Owner: $OWNER"
echo " Version: $VERSION"
echo ""
# Step 1: Check if remote directory exists
log_info "Checking remote directory..."
if ! ssh "$REMOTE_HOST" "[ -d $REMOTE_DIR ]"; then
log_error "Remote directory $REMOTE_DIR does not exist!"
log_info "Creating remote directory..."
ssh "$REMOTE_HOST" "mkdir -p $REMOTE_DIR"
fi
log_success "Remote directory exists"
# Step 2: Sync code to remote server
log_info "Syncing code to remote server..."
rsync -avz --exclude='.git' \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='.venv' \
--exclude='venv' \
--exclude='node_modules' \
--exclude='.pytest_cache' \
--exclude='.mypy_cache' \
--exclude='.ruff_cache' \
--exclude='*.egg-info' \
--exclude='.DS_Store' \
./ "$REMOTE_HOST:$REMOTE_DIR/"
log_success "Code synced to remote server"
# Step 3: Build base-ml on remote
log_info "Building base-ml image on remote server..."
log_warning "This will take 10-15 minutes (installing ML dependencies)..."
ssh "$REMOTE_HOST" << 'ENDSSH'
set -e
cd /home/deploy/ai-tax-agent
# Build base-ml image
echo "Building base-ml image..."
docker build \
-f infra/docker/base-ml.Dockerfile \
-t gitea.harkon.co.uk/harkon/base-ml:v1.0.1 \
-t gitea.harkon.co.uk/harkon/base-ml:latest \
.
# Push to registry
echo "Pushing base-ml image to registry..."
docker push gitea.harkon.co.uk/harkon/base-ml:v1.0.1
docker push gitea.harkon.co.uk/harkon/base-ml:latest
# Show image size
echo ""
echo "=== Base ML Image Built ==="
docker images | grep "base-ml"
echo ""
ENDSSH
log_success "base-ml image built and pushed from remote server!"
# Step 4: Verify image is available
log_info "Verifying image is available in registry..."
log_info "You can check at: https://$REGISTRY/$OWNER/-/packages/container/base-ml"
log_success "Done! base-ml image is ready to use."
log_info "Next steps:"
echo " 1. Pull base-ml locally (optional): docker pull $REGISTRY/$OWNER/base-ml:$VERSION"
echo " 2. Build ML services: ./scripts/build-and-push-images.sh $REGISTRY $VERSION $OWNER"