#!/bin/sh # --------------------------------------------------------------------------- # init-volumes.sh — One-shot init container script. # # Copies runtime data assets from the data image into mounted volumes. # Runs as part of docker-compose.runtime-assets.yml and exits when done. # # Mount points (set via environment or defaults): # MODELS_DEST /mnt/models -> ML model weights # CERTS_DEST /mnt/certificates -> Certificates and trust bundles # LICENSES_DEST /mnt/licenses -> License attribution files # --------------------------------------------------------------------------- set -e MODELS_DEST="${MODELS_DEST:-/mnt/models}" CERTS_DEST="${CERTS_DEST:-/mnt/certificates}" LICENSES_DEST="${LICENSES_DEST:-/mnt/licenses}" log() { echo "[init-volumes] $*"; } # Models if [ -d /data/models ] && [ "$(ls -A /data/models 2>/dev/null)" ]; then log "Copying ML models to $MODELS_DEST..." mkdir -p "$MODELS_DEST" cp -rn /data/models/* "$MODELS_DEST/" 2>/dev/null || cp -r /data/models/* "$MODELS_DEST/" log " Models ready." else log " No models found in /data/models (semantic search will use fallback)." fi # Certificates if [ -d /data/certificates ] && [ "$(ls -A /data/certificates 2>/dev/null)" ]; then log "Copying certificates to $CERTS_DEST..." mkdir -p "$CERTS_DEST" cp -rn /data/certificates/* "$CERTS_DEST/" 2>/dev/null || cp -r /data/certificates/* "$CERTS_DEST/" log " Certificates ready." else log " No certificates found in /data/certificates." fi # Licenses if [ -d /data/licenses ] && [ "$(ls -A /data/licenses 2>/dev/null)" ]; then log "Copying license files to $LICENSES_DEST..." mkdir -p "$LICENSES_DEST" cp -rn /data/licenses/* "$LICENSES_DEST/" 2>/dev/null || cp -r /data/licenses/* "$LICENSES_DEST/" log " Licenses ready." else log " No license files found in /data/licenses." fi # Verify ONNX model is real (not placeholder) ONNX_FILE="$MODELS_DEST/all-MiniLM-L6-v2.onnx" if [ -f "$ONNX_FILE" ]; then SIZE=$(wc -c < "$ONNX_FILE" 2>/dev/null || echo 0) if [ "$SIZE" -lt 1000 ]; then log " WARNING: ONNX model at $ONNX_FILE is only $SIZE bytes (placeholder?)." log " Run ./devops/runtime-assets/acquire.sh --models to download real weights." else log " ONNX model verified: $SIZE bytes." fi fi log "Init complete."