#!/bin/sh
# Run a script from this folder inside the pinecone image.
# DATA_DIR (host) holds chunks.jsonl, mounted at /data.
# PINECONE_ENV_FILE (host, mode 600) holds one line: PINECONE_API_KEY=... It reaches the container only through --env-file.
# Usage: ./run.sh load.py [args]
: "${DATA_DIR:?set DATA_DIR to a host folder with chunks.jsonl}"
: "${PINECONE_ENV_FILE:?set PINECONE_ENV_FILE to a file with PINECONE_API_KEY}"
exec docker run --rm \
  --user "$(id -u):$(id -g)" -e HOME=/tmp \
  --env-file "$PINECONE_ENV_FILE" \
  --add-host host.docker.internal:host-gateway \
  -v "$DATA_DIR":/data \
  -v "$(cd "$(dirname "$0")" && pwd)":/work:ro \
  -e CHUNKS_PATH=/data/chunks.jsonl \
  -e OLLAMA_URL="http://host.docker.internal:11434" \
  kb-pinecone:10.3.0 python "$@"
