Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ GCP__ZONE=us-central1-a
GCP__MACHINE_TYPE=c3-standard-4
GCP__SERVICE_ACCOUNT=confidential-sa@verifiable-ai-hackathon.iam.gserviceaccount.com
GCP__TEE_IMAGE_REFERENCE=ghcr.io/flare-foundation/flare-ai-kit:main
# For production, use `confidential-space-250301`
GCP__CONFIDENTIAL_IMAGE=confidential-space-debug-250301
# For production, use `family/confidential-space`
GCP__CONFIDENTIAL_IMAGE=family/confidential-space-debug
# For production, use `false`
GCP__TEE_CONTAINER_LOG_REDIRECT=true
# Use either TDX or SEV
GCP__CONFIDENTIAL_COMPUTE_TYPE=TDX
GCP__SCOPES=https://www.googleapis.com/auth/cloud-platform
GCP__TAGS=flare-ai,http-server,https-server
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
name: Docker Scripts Validation
name: Agents Validation

on:
push:
branches: ["main"]
paths:
- "Dockerfile"
- "scripts/**"
- "pyproject.toml"
- "uv.lock"
pull_request:
branches: ["main"]
branches:
- main
paths:
- ".github/workflows/docker-agents.yml"
- "Dockerfile"
- "scripts/**"
- "agents/**"
- "pyproject.toml"
- "uv.lock"

permissions:
contents: read

jobs:
validate-docker-scripts:
validate-docker-agents:
runs-on: ubuntu-latest

strategy:
matrix:
script:
agent:
- name: "PDF Ingestion"
extras: "pdf"
script_file: "ingest_pdf.py"
filename: "ingest_pdf.py"
test_timeout: "300" # 5 minutes

env:
# Test environment variables
LOG_LEVEL: INFO
AGENT__GEMINI_MODEL: "gemini-2.0-flash"
AGENT__GEMINI_API_KEY: ${{ secrets.AGENT__GEMINI_API_KEY }}
Expand All @@ -47,46 +40,46 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image for ${{ matrix.script.name }}
- name: Build Docker image for ${{ matrix.agent.name }}
run: |
docker build \
--build-arg EXTRAS=${{ matrix.script.extras }} \
--build-arg SCRIPT=${{ matrix.script.script_file }} \
--tag fai-script-${{ matrix.script.extras }} \
--build-arg EXTRAS=${{ matrix.agent.extras }} \
--build-arg AGENT=${{ matrix.agent.filename }} \
--tag fai-agent-${{ matrix.agent.extras }} \
--cache-from type=gha \
--cache-to type=gha,mode=max \
.

- name: Validate script exists in image
- name: Validate agent script exists in image
run: |
docker run --rm fai-script-${{ matrix.script.extras }} \
test -f "/app/scripts/${{ matrix.script.script_file }}"
docker run --rm fai-agent-${{ matrix.agent.extras }} \
test -f "/app/agents/${{ matrix.agent.filename }}"

- name: Test script startup (dry run)
- name: Test agent startup (dry run)
timeout-minutes: 5
run: |
# Simple validation that the script exists and dependencies are available
# Simple validation that the agent exists and dependencies are available
docker run --rm \
-e LOG_LEVEL="$LOG_LEVEL" \
-e AGENT__GEMINI_MODEL="$AGENT__GEMINI_MODEL" \
-e AGENT__GEMINI_API_KEY="$AGENT__GEMINI_API_KEY" \
-e ECOSYSTEM__WEB3_PROVIDER_URL="$ECOSYSTEM__WEB3_PROVIDER_URL" \
-e INGESTION__CHUNK_SIZE="$INGESTION__CHUNK_SIZE" \
-e TEE__SIMULATE_ATTESTATION_TOKEN="$TEE__SIMULATE_ATTESTATION_TOKEN" \
fai-script-${{ matrix.script.extras }} \
fai-agent-${{ matrix.agent.extras }} \
python -c "
import sys
import os

# Test that script file exists
script_path = '/app/scripts/${{ matrix.script.script_file }}'
if not os.path.exists(script_path):
print(f'❌ Script not found: {script_path}')
# Test that agent file exists
agent_path = '/app/agents/${{ matrix.agent.filename }}'
if not os.path.exists(agent_path):
print(f'❌ Agent not found: {agent_path}')
sys.exit(1)
print(f'✅ Script exists: {script_path}')
print(f'✅ Agent exists: {agent_path}')

# Test that required dependencies are available
if '${{ matrix.script.extras }}' == 'pdf':
if '${{ matrix.agent.extras }}' == 'pdf':
try:
import PIL
import fitz # pymupdf
Expand All @@ -96,25 +89,24 @@ jobs:
print(f'❌ PDF dependency missing: {e}')
sys.exit(1)

print('✅ Script validation completed successfully')
print('✅ Agent validation completed successfully')
"

- name: Test container health
run: |
# Test that the container can start and the Python environment is healthy
docker run --rm fai-script-${{ matrix.script.extras }} \
docker run --rm fai-agent-${{ matrix.agent.extras }} \
python -c "
import sys
print(f'Python version: {sys.version}')
print(f'Python path: {sys.path}')

# Test core dependencies (some modules may require optional deps)
# Test core dependencies
try:
import flare_ai_kit
print('✅ flare-ai-kit imported successfully')
except ImportError as e:
print(f'⚠️ flare-ai-kit import issue (may need more extras): {e}')
# Test basic Python packages instead
print(f'⚠️ flare-ai-kit import issue: {e}')
import httpx, pydantic, structlog
print('✅ Core Python dependencies available')

Expand All @@ -127,16 +119,15 @@ jobs:
print('✅ Container health check passed')
"

- name: Test script dependencies for ${{ matrix.script.name }}
- name: Test agent dependencies for ${{ matrix.agent.name }}
run: |
# Test that the specific extras are properly installed
docker run --rm fai-script-${{ matrix.script.extras }} \
docker run --rm fai-agent-${{ matrix.agent.extras }} \
python -c "
import sys

extras = '${{ matrix.script.extras }}'
extras = '${{ matrix.agent.extras }}'
print(f'Testing dependencies for extras: {extras}')

if 'pdf' in extras:
try:
import PIL
Expand All @@ -146,7 +137,7 @@ jobs:
except ImportError as e:
print(f'❌ PDF dependency missing: {e}')
sys.exit(1)

if 'rag' in extras:
try:
import qdrant_client
Expand All @@ -155,23 +146,21 @@ jobs:
except ImportError as e:
print(f'❌ RAG dependency missing: {e}')
sys.exit(1)

if 'a2a' in extras:
try:
import fastapi
print('✅ A2A dependencies (fastapi) available')
except ImportError as e:
print(f'❌ A2A dependency missing: {e}')
sys.exit(1)

print('✅ All expected dependencies are available')
"



validate-build-args:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6
Expand All @@ -182,21 +171,21 @@ jobs:
- name: Test build without extras
run: |
docker build \
--build-arg SCRIPT=ingest_pdf.py \
--tag fai-script-base \
--build-arg AGENT=ingest_pdf.py \
--tag fai-agent-base \
.

- name: Test build with multiple extras
run: |
docker build \
--build-arg EXTRAS=pdf,rag \
--build-arg SCRIPT=ingest_pdf.py \
--tag fai-script-multi \
--build-arg AGENT=ingest_pdf.py \
--tag fai-agent-multi \
.

- name: Validate multi-extras build
run: |
docker run --rm fai-script-multi \
docker run --rm fai-agent-multi \
python -c "
import PIL, fitz, pytesseract # PDF deps
import qdrant_client, dulwich # RAG deps
Expand All @@ -205,27 +194,27 @@ jobs:

validate-documentation:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Check documentation exists
run: |
test -f docs/docker_scripts_guide.md
echo "✅ Docker scripts guide exists"
test -f docs/docker_agents_guide.md
echo "✅ Docker agents guide exists"

- name: Validate README updates
run: |
grep -q "parametric Dockerfile" README.md
grep -q "EXTRAS" README.md
grep -q "docker_scripts_guide.md" README.md
echo "✅ README contains Docker scripts documentation"
echo "✅ README contains Docker agents documentation"

- name: Check scripts directory structure
- name: Check agents directory structure
run: |
test -d scripts
test -f scripts/ingest_pdf.py
test -d scripts/data
test -f scripts/data/create_sample_invoice.py
echo "✅ Scripts directory structure is correct"
test -d agents
test -f agents/ingest_pdf.py
test -d agents/data
test -f agents/data/create_sample_invoice.py

echo "✅ Agents directory structure is correct"
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ FROM python:3.12-slim-bookworm AS runtime

# Pass build args to runtime stage
ARG EXTRAS
ARG SCRIPT
ARG AGENT

# Install runtime system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand All @@ -73,7 +73,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

ENV PIP_NO_CACHE_DIR=1 \
UV_PYTHON_DOWNLOADS=0 \
SCRIPT_NAME="$SCRIPT" \
AGENT_NAME="$AGENT" \
PYTHONPATH="/app/scripts:/app:$PYTHONPATH"

# Create non-root user
Expand All @@ -90,8 +90,8 @@ ENV PATH="/app/.venv/bin:$PATH"
# Switch to non-root user
USER app

# Validate that the script exists
RUN test -f "/app/scripts/$SCRIPT" || (echo "Error: Script /app/scripts/$SCRIPT not found" && exit 1)
# Validate that the agent exists
RUN test -f "/app/agents/$AGENT" || (echo "Error: Script /app/agents/$AGENT not found" && exit 1)

# Default command runs the specified script
CMD ["sh", "-c", "python \"/app/scripts/$SCRIPT_NAME\""]
# Default command runs the specified agent
CMD ["sh", "-c", "python \"/app/agents/$AGENT_NAME\""]
Loading