Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1fd1b11a1 | |||
| 6f3b21ab17 | |||
| 566f0f6ea2 | |||
| 340c54b3d8 | |||
| 8d0bc59d28 | |||
| f969724ee4 | |||
| ffd2678c91 | |||
| 365f110f9c | |||
| 59d40241e2 | |||
| 51fb30646c |
63
.gitea/workflows/ci.yml
Normal file
63
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
name: CI/CD Awesome Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
REGISTRY_URL: ${{ vars.REGISTRY_URL || 'gitea.iswearihadsomethingforthis.net' }}
|
||||
REGISTRY_USER: ${{ vars.REGISTRY_USER || 'francwa' }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build and run tests
|
||||
env:
|
||||
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
|
||||
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
|
||||
run: make _ci-run-tests
|
||||
|
||||
build-and-push:
|
||||
name: Build & Push to Registry
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
|
||||
steps:
|
||||
- name: Debug ref
|
||||
run: |
|
||||
echo "github.ref = ${{ github.ref }}"
|
||||
echo "github.ref_type = ${{ github.ref_type }}"
|
||||
echo "github.ref_name = ${{ github.ref_name }}"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Load config from Makefile
|
||||
id: config
|
||||
run: |
|
||||
eval "$(make _ci-image-name)"
|
||||
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build production image
|
||||
run: make build
|
||||
|
||||
- name: Tag and push to registry
|
||||
run: |
|
||||
docker tag ${{ steps.config.outputs.image_name }}:latest ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:${{ steps.version.outputs.version }}
|
||||
docker tag ${{ steps.config.outputs.image_name }}:latest ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:latest
|
||||
echo "${{ secrets.GITEA_TOKEN }}" | docker login ${{ env.REGISTRY_URL }} -u ${{ env.REGISTRY_USER }} --password-stdin
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:${{ steps.version.outputs.version }}
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USER }}/${{ steps.config.outputs.image_name }}:latest
|
||||
@@ -18,18 +18,18 @@ repos:
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
name: Ruff Linter
|
||||
entry: bash -c 'cd brain && poetry run ruff check --fix'
|
||||
entry: bash -c 'make lint'
|
||||
language: system
|
||||
types: [python]
|
||||
|
||||
- id: ruff-format
|
||||
name: Ruff Formatter
|
||||
entry: bash -c 'cd brain && poetry run ruff format'
|
||||
entry: bash -c 'make format'
|
||||
language: system
|
||||
types: [python]
|
||||
|
||||
- id: system-pytest
|
||||
name: Pytest
|
||||
entry: bash -c 'cd brain && poetry run pytest -n auto --dist=loadscope'
|
||||
entry: bash -c 'make test'
|
||||
language: system
|
||||
always_run: true
|
||||
|
||||
268
Makefile
268
Makefile
@@ -1,25 +1,249 @@
|
||||
# Versioning
|
||||
check-branch-is-main:
|
||||
@current_branch=$$(git rev-parse --abbrev-ref HEAD); \
|
||||
if [ "$$current_branch" != "main" ]; then \
|
||||
echo "Error: not on the main branch" \
|
||||
exit 1; \
|
||||
.POSIX:
|
||||
.SUFFIXES:
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# --- SETTINGS ---
|
||||
PYTHON_VERSION = 3.12.7
|
||||
PYTHON_VERSION_SHORT = $(shell echo $(PYTHON_VERSION) | cut -d. -f1,2)
|
||||
# Change to 'uv' when ready.
|
||||
RUNNER ?= poetry
|
||||
|
||||
export PYTHON_VERSION
|
||||
export PYTHON_VERSION_SHORT
|
||||
export RUNNER
|
||||
export IMAGE_NAME
|
||||
|
||||
# --- VARIABLES ---
|
||||
CORE_DIR = brain
|
||||
SERVICE_NAME = agent_media
|
||||
IMAGE_NAME = agent_media
|
||||
|
||||
# --- ADAPTERS ---
|
||||
# UV uses "sync", Poetry uses "install". Both install DEV deps by default.
|
||||
INSTALL_CMD = $(if $(filter uv,$(RUNNER)),sync,install)
|
||||
|
||||
# --- MACROS ---
|
||||
ARGS = $(filter-out $@,$(MAKECMDGOALS))
|
||||
BUMP_CMD = cd $(CORE_DIR) && $(RUNNER) run bump-my-version bump
|
||||
COMPOSE_CMD = docker-compose
|
||||
DOCKER_CMD = docker build \
|
||||
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
|
||||
--build-arg PYTHON_VERSION_SHORT=$(PYTHON_VERSION_SHORT) \
|
||||
--build-arg RUNNER=$(RUNNER) \
|
||||
-f $(CORE_DIR)/Dockerfile \
|
||||
-t $(IMAGE_NAME):latest .
|
||||
|
||||
RUNNER_ADD = cd $(CORE_DIR) && $(RUNNER) add
|
||||
RUNNER_HOOKS = cd $(CORE_DIR) && $(RUNNER) run pre-commit install -c ../.pre-commit-config.yaml
|
||||
RUNNER_INSTALL = cd $(CORE_DIR) && $(RUNNER) $(INSTALL_CMD)
|
||||
RUNNER_RUN = cd $(CORE_DIR) && $(RUNNER) run
|
||||
RUNNER_UPDATE = cd $(CORE_DIR) && $(RUNNER) update
|
||||
|
||||
# --- STYLES ---
|
||||
B = \033[1m
|
||||
G = \033[32m
|
||||
T = \033[36m
|
||||
R = \033[0m
|
||||
|
||||
# --- TARGETS ---
|
||||
.PHONY: add build build-test check-docker check-runner clean coverage down format help init-dotenv install install-hooks lint logs major minor patch prune ps restart run shell test up update _check_branch _ci-image-name _ci-run-tests
|
||||
|
||||
# Catch-all for args
|
||||
%:
|
||||
@:
|
||||
|
||||
add: check-runner
|
||||
@echo "$(T)➕ Adding dependency ($(RUNNER)): $(ARGS)$(R)"
|
||||
$(RUNNER_ADD) $(ARGS)
|
||||
|
||||
build: check-docker
|
||||
@echo "$(T)🐳 Building Docker image...$(R)"
|
||||
$(DOCKER_CMD)
|
||||
@echo "✅ Image $(IMAGE_NAME):latest ready."
|
||||
|
||||
build-test: check-docker
|
||||
@echo "$(T)🐳 Building test image (with dev deps)...$(R)"
|
||||
docker build \
|
||||
--build-arg RUNNER=$(RUNNER) \
|
||||
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
|
||||
--build-arg PYTHON_VERSION_SHORT=$(PYTHON_VERSION_SHORT) \
|
||||
-f $(CORE_DIR)/Dockerfile \
|
||||
--target test \
|
||||
-t $(IMAGE_NAME):test .
|
||||
@echo "✅ Test image $(IMAGE_NAME):test ready."
|
||||
|
||||
check-docker:
|
||||
@command -v docker >/dev/null 2>&1 || { echo "$(R)❌ Docker not installed$(R)"; exit 1; }
|
||||
@docker info >/dev/null 2>&1 || { echo "$(R)❌ Docker daemon not running$(R)"; exit 1; }
|
||||
|
||||
check-runner:
|
||||
@command -v $(RUNNER) >/dev/null 2>&1 || { echo "$(R)❌ $(RUNNER) not installed$(R)"; exit 1; }
|
||||
|
||||
clean:
|
||||
@echo "$(T)🧹 Cleaning caches...$(R)"
|
||||
cd $(CORE_DIR) && rm -rf .ruff_cache __pycache__ .pytest_cache
|
||||
find $(CORE_DIR) -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
||||
find $(CORE_DIR) -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
|
||||
find $(CORE_DIR) -type f -name "*.pyc" -delete 2>/dev/null || true
|
||||
@echo "✅ Caches cleaned."
|
||||
|
||||
coverage: check-runner
|
||||
@echo "$(T)📊 Running tests with coverage...$(R)"
|
||||
$(RUNNER_RUN) pytest --cov=. --cov-report=html --cov-report=term $(ARGS)
|
||||
@echo "✅ Report generated in htmlcov/"
|
||||
|
||||
down: check-docker
|
||||
@echo "$(T)🛑 Stopping containers...$(R)"
|
||||
$(COMPOSE_CMD) down
|
||||
@echo "✅ System stopped."
|
||||
|
||||
format: check-runner
|
||||
@echo "$(T)✨ Formatting with Ruff...$(R)"
|
||||
$(RUNNER_RUN) ruff format .
|
||||
$(RUNNER_RUN) ruff check --fix .
|
||||
@echo "✅ Code cleaned."
|
||||
|
||||
help:
|
||||
@echo "$(B)Available commands:$(R)"
|
||||
@echo ""
|
||||
@echo "$(G)Setup:$(R)"
|
||||
@echo " $(T)check-docker $(R) Verify Docker is installed and running."
|
||||
@echo " $(T)check-runner $(R) Verify package manager ($(RUNNER))."
|
||||
@echo " $(T)init-dotenv $(R) Create .env from .env.example with generated secrets."
|
||||
@echo " $(T)install $(R) Install ALL dependencies (Prod + Dev)."
|
||||
@echo " $(T)install-hooks $(R) Install git pre-commit hooks."
|
||||
@echo ""
|
||||
@echo "$(G)Docker:$(R)"
|
||||
@echo " $(T)build $(R) Build the docker image (production)."
|
||||
@echo " $(T)build-test $(R) Build the docker image (with dev deps for testing)."
|
||||
@echo " $(T)down $(R) Stop and remove containers."
|
||||
@echo " $(T)logs $(R) Follow logs."
|
||||
@echo " $(T)prune $(R) Clean Docker system."
|
||||
@echo " $(T)ps $(R) Show container status."
|
||||
@echo " $(T)restart $(R) Restart all containers."
|
||||
@echo " $(T)shell $(R) Open shell in container."
|
||||
@echo " $(T)up $(R) Start the agent."
|
||||
@echo ""
|
||||
@echo "$(G)Development:$(R)"
|
||||
@echo " $(T)add ... $(R) Add dependency (use --group dev or --dev if needed)."
|
||||
@echo " $(T)clean $(R) Clean caches."
|
||||
@echo " $(T)coverage $(R) Run tests with coverage."
|
||||
@echo " $(T)format $(R) Format code (Ruff)."
|
||||
@echo " $(T)lint $(R) Lint code without fixing."
|
||||
@echo " $(T)test ... $(R) Run tests (local with $(RUNNER))."
|
||||
@echo " $(T)update $(R) Update dependencies."
|
||||
@echo ""
|
||||
@echo "$(G)Versioning:$(R)"
|
||||
@echo " $(T)major/minor/patch $(R) Bump version."
|
||||
|
||||
init-dotenv:
|
||||
@echo "$(T)🔑 Initializing .env file...$(R)"
|
||||
@if [ -f .env ]; then \
|
||||
echo "$(R)⚠️ .env already exists. Skipping.$(R)"; \
|
||||
exit 0; \
|
||||
fi
|
||||
@if [ ! -f .env.example ]; then \
|
||||
echo "$(R)❌ .env.example not found$(R)"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if ! command -v openssl >/dev/null 2>&1; then \
|
||||
echo "$(R)❌ openssl not found. Please install it first.$(R)"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "$(T) → Copying .env.example...$(R)"
|
||||
@cp .env.example .env
|
||||
@echo "$(T) → Generating secrets...$(R)"
|
||||
@sed -i.bak "s|JWT_SECRET=.*|JWT_SECRET=$$(openssl rand -base64 32)|" .env
|
||||
@sed -i.bak "s|JWT_REFRESH_SECRET=.*|JWT_REFRESH_SECRET=$$(openssl rand -base64 32)|" .env
|
||||
@sed -i.bak "s|CREDS_KEY=.*|CREDS_KEY=$$(openssl rand -hex 16)|" .env
|
||||
@sed -i.bak "s|CREDS_IV=.*|CREDS_IV=$$(openssl rand -hex 8)|" .env
|
||||
@sed -i.bak "s|MEILI_MASTER_KEY=.*|MEILI_MASTER_KEY=$$(openssl rand -base64 32)|" .env
|
||||
@sed -i.bak "s|AGENT_BRAIN_API_KEY=.*|AGENT_BRAIN_API_KEY=$$(openssl rand -base64 24)|" .env
|
||||
@rm -f .env.bak
|
||||
@echo "$(G)✅ .env created with generated secrets!$(R)"
|
||||
@echo "$(T)⚠️ Don't forget to add your API keys:$(R)"
|
||||
@echo " - OPENAI_API_KEY"
|
||||
@echo " - DEEPSEEK_API_KEY"
|
||||
@echo " - TMDB_API_KEY (optional)"
|
||||
|
||||
install: check-runner
|
||||
@echo "$(T)📦 Installing FULL environment ($(RUNNER))...$(R)"
|
||||
$(RUNNER_INSTALL)
|
||||
@echo "✅ Environment ready (Prod + Dev)."
|
||||
|
||||
install-hooks: check-runner
|
||||
@echo "$(T)🔧 Installing hooks...$(R)"
|
||||
$(RUNNER_HOOKS)
|
||||
@echo "✅ Hooks ready."
|
||||
|
||||
lint: check-runner
|
||||
@echo "$(T)🔍 Linting code...$(R)"
|
||||
$(RUNNER_RUN) ruff check .
|
||||
|
||||
logs: check-docker
|
||||
@echo "$(T)📋 Following logs...$(R)"
|
||||
$(COMPOSE_CMD) logs -f
|
||||
|
||||
major: _check_branch
|
||||
@echo "$(T)💥 Bumping major...$(R)"
|
||||
SKIP=all $(BUMP_CMD) major
|
||||
|
||||
minor: _check_branch
|
||||
@echo "$(T)✨ Bumping minor...$(R)"
|
||||
SKIP=all $(BUMP_CMD) minor
|
||||
|
||||
patch: _check_branch
|
||||
@echo "$(T)🚀 Bumping patch...$(R)"
|
||||
SKIP=all $(BUMP_CMD) patch
|
||||
|
||||
prune: check-docker
|
||||
@echo "$(T)🗑️ Pruning Docker resources...$(R)"
|
||||
docker system prune -af
|
||||
@echo "✅ Docker cleaned."
|
||||
|
||||
ps: check-docker
|
||||
@echo "$(T)📋 Container status:$(R)"
|
||||
@$(COMPOSE_CMD) ps
|
||||
|
||||
restart: check-docker
|
||||
@echo "$(T)🔄 Restarting containers...$(R)"
|
||||
$(COMPOSE_CMD) restart
|
||||
@echo "✅ Containers restarted."
|
||||
|
||||
run: check-runner
|
||||
$(RUNNER_RUN) $(ARGS)
|
||||
|
||||
shell: check-docker
|
||||
@echo "$(T)🐚 Opening shell in $(SERVICE_NAME)...$(R)"
|
||||
$(COMPOSE_CMD) exec $(SERVICE_NAME) /bin/sh
|
||||
|
||||
test: check-runner
|
||||
@echo "$(T)🧪 Running tests...$(R)"
|
||||
$(RUNNER_RUN) pytest $(ARGS)
|
||||
|
||||
up: check-docker
|
||||
@echo "$(T)🚀 Starting Agent Media...$(R)"
|
||||
$(COMPOSE_CMD) up -d
|
||||
@echo "✅ System is up."
|
||||
|
||||
update: check-runner
|
||||
@echo "$(T)🔄 Updating dependencies...$(R)"
|
||||
$(RUNNER_UPDATE)
|
||||
@echo "✅ All packages up to date."
|
||||
|
||||
_check_branch:
|
||||
@curr=$$(git rev-parse --abbrev-ref HEAD); \
|
||||
if [ "$$curr" != "main" ]; then \
|
||||
echo "❌ Error: not on the main branch"; exit 1; \
|
||||
fi
|
||||
|
||||
BUMP = cd brain && poetry run bump-my-version bump
|
||||
_ci-image-name:
|
||||
@echo "IMAGE_NAME=$(IMAGE_NAME)"
|
||||
|
||||
.PHONY: help patch minor major
|
||||
help:
|
||||
@echo "Versioning commands :"
|
||||
@echo " make patch : Bump version 0.0.1 (bugfix)"
|
||||
@echo " make minor : Bump version 0.1.0 (feature)"
|
||||
@echo " make major : Bump version 1.0.0 (breaking change)"
|
||||
|
||||
patch: check-branch-is-main
|
||||
SKIP=all $(BUMP) patch
|
||||
|
||||
minor: check-branch-is-main
|
||||
SKIP=all $(BUMP) minor
|
||||
|
||||
major: check-branch-is-main
|
||||
SKIP=all $(BUMP) major
|
||||
_ci-run-tests: build-test
|
||||
@echo "$(T)🧪 Running tests in Docker...$(R)"
|
||||
docker run --rm \
|
||||
-e DEEPSEEK_API_KEY \
|
||||
-e TMDB_API_KEY \
|
||||
$(IMAGE_NAME):test pytest
|
||||
@echo "✅ Tests passed."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[tool.bumpversion]
|
||||
current_version = "0.1.1"
|
||||
current_version = "0.1.3"
|
||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||
serialize = ["{major}.{minor}.{patch}"]
|
||||
search = "{current_version}"
|
||||
|
||||
105
brain/Dockerfile
105
brain/Dockerfile
@@ -1,47 +1,85 @@
|
||||
# Dockerfile for Agent Media
|
||||
# Multi-stage build for smaller image size
|
||||
|
||||
ARG PYTHON_VERSION
|
||||
ARG PYTHON_VERSION_SHORT
|
||||
ARG RUNNER
|
||||
# ===========================================
|
||||
# Stage 1: Builder
|
||||
# ===========================================
|
||||
FROM python:3.12.7-slim as builder
|
||||
FROM python:${PYTHON_VERSION}-slim-bookworm AS builder
|
||||
|
||||
# STFU (please)
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
# Re-declare ARGs after FROM to make them available in this stage
|
||||
ARG RUNNER
|
||||
|
||||
# STFU - No need - Write logs asap
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Install build dependencies (needs root)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Poetry globally (needs root)
|
||||
RUN pip install --no-cache-dir poetry
|
||||
# Install runner globally (needs root) - Save cache for future
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install $RUNNER
|
||||
|
||||
# Copy dependency files (as root for now)
|
||||
COPY pyproject.toml poetry.lock* /tmp/
|
||||
# Set working directory for dependency installation
|
||||
WORKDIR /tmp
|
||||
|
||||
# Copy dependency files
|
||||
COPY brain/pyproject.toml brain/poetry.lock* brain/uv.lock* Makefile ./
|
||||
|
||||
# Install dependencies as root (to avoid permission issues with system packages)
|
||||
WORKDIR /tmp
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --only main --no-root --no-cache
|
||||
|
||||
# Create non-root user
|
||||
RUN useradd -m -u 1000 -s /bin/bash appuser
|
||||
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
# Set working directory (owned by appuser)
|
||||
WORKDIR /home/appuser/app
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=cache,target=/root/.cache/pypoetry \
|
||||
--mount=type=cache,target=/root/.cache/uv \
|
||||
if [ "$RUNNER" = "poetry" ]; then \
|
||||
poetry config virtualenvs.create false && \
|
||||
poetry install --only main --no-root; \
|
||||
elif [ "$RUNNER" = "uv" ]; then \
|
||||
uv pip install --system -r pyproject.toml; \
|
||||
fi
|
||||
|
||||
# ===========================================
|
||||
# Stage 2: Runtime
|
||||
# Stage 2: Testing
|
||||
# ===========================================
|
||||
FROM python:3.12.7-slim as runtime
|
||||
FROM builder AS test
|
||||
|
||||
ARG RUNNER
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=cache,target=/root/.cache/pypoetry \
|
||||
--mount=type=cache,target=/root/.cache/uv \
|
||||
if [ "$RUNNER" = "poetry" ]; then \
|
||||
poetry install --no-root; \
|
||||
elif [ "$RUNNER" = "uv" ]; then \
|
||||
uv pip install --system -e .[dev]; \
|
||||
fi
|
||||
|
||||
COPY brain/agent/ ./agent/
|
||||
COPY brain/application/ ./application/
|
||||
COPY brain/domain/ ./domain/
|
||||
COPY brain/infrastructure/ ./infrastructure/
|
||||
COPY brain/tests/ ./tests/
|
||||
COPY brain/app.py .
|
||||
|
||||
# ===========================================
|
||||
# Stage 3: Runtime
|
||||
# ===========================================
|
||||
FROM python:${PYTHON_VERSION}-slim-bookworm AS runtime
|
||||
|
||||
ARG PYTHON_VERSION_SHORT
|
||||
|
||||
ENV LLM_PROVIDER=deepseek \
|
||||
MEMORY_STORAGE_DIR=/data/memory \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONPATH=/home/appuser/app \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Install runtime dependencies (needs root)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& apt-get clean
|
||||
@@ -60,15 +98,15 @@ USER appuser
|
||||
WORKDIR /home/appuser/app
|
||||
|
||||
# Copy Python packages from builder stage
|
||||
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
||||
COPY --from=builder /usr/local/lib/python${PYTHON_VERSION_SHORT}/site-packages /usr/local/lib/python${PYTHON_VERSION_SHORT}/site-packages
|
||||
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||
|
||||
# Copy application code (already owned by appuser)
|
||||
COPY --chown=appuser:appuser agent/ ./agent/
|
||||
COPY --chown=appuser:appuser application/ ./application/
|
||||
COPY --chown=appuser:appuser domain/ ./domain/
|
||||
COPY --chown=appuser:appuser infrastructure/ ./infrastructure/
|
||||
COPY --chown=appuser:appuser app.py .
|
||||
COPY --chown=appuser:appuser brain/agent/ ./agent/
|
||||
COPY --chown=appuser:appuser brain/application/ ./application/
|
||||
COPY --chown=appuser:appuser brain/domain/ ./domain/
|
||||
COPY --chown=appuser:appuser brain/infrastructure/ ./infrastructure/
|
||||
COPY --chown=appuser:appuser brain/app.py .
|
||||
|
||||
# Create volumes for persistent data
|
||||
VOLUME ["/data/memory", "/data/logs"]
|
||||
@@ -78,14 +116,7 @@ EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Environment variables (can be overridden)
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONPATH=/home/appuser/app \
|
||||
LLM_PROVIDER=deepseek \
|
||||
MEMORY_STORAGE_DIR=/data/memory
|
||||
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=5).raise_for_status()" || exit 1
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
||||
2
brain/poetry.lock
generated
2
brain/poetry.lock
generated
@@ -1220,4 +1220,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "6204ac4c938e73f59f5bffef08e8e3cdbbc5c307a693578b1183d6140d4e8f31"
|
||||
content-hash = "b6cec0647accef2c235cededb06cab49f30033fb5e5ce1f6b589a4da5d2a2d8d"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "agent-media"
|
||||
version = "0.1.1"
|
||||
version = "0.1.3"
|
||||
description = "AI agent for managing a local media library"
|
||||
authors = ["Francwa <francois.hodiaumont@gmail.com>"]
|
||||
readme = "README.md"
|
||||
@@ -47,6 +47,7 @@ addopts = [
|
||||
#"--cov-report=xml", # Génère un rapport XML (pour CI/CD)
|
||||
#"--cov-fail-under=80", # Échoue si coverage < 80%
|
||||
"-n=auto", # --numprocesses=auto : parallélise les tests (pytest-xdist)
|
||||
"--dist=loadscope", # Distribution strategy: group tests by module
|
||||
"--strict-markers", # Erreur si un marker non déclaré est utilisé
|
||||
"--disable-warnings", # Désactive l'affichage des warnings (sauf erreurs)
|
||||
]
|
||||
|
||||
@@ -6,6 +6,8 @@ services:
|
||||
build:
|
||||
context: ./brain
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
RUNNER: ${RUNNER} # Get it from Makefile
|
||||
container_name: agent-brain
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
|
||||
Reference in New Issue
Block a user