Compare commits
3 Commits
afc0024b37
..
v0.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 340c54b3d8 | |||
| 8d0bc59d28 | |||
| f969724ee4 |
@@ -21,6 +21,9 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build and run tests
|
- 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
|
run: make _ci-run-tests
|
||||||
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
|
|||||||
@@ -3,9 +3,15 @@
|
|||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
# --- SETTINGS ---
|
# --- SETTINGS ---
|
||||||
|
PYTHON_VERSION = 3.12.7
|
||||||
|
PYTHON_VERSION_SHORT = $(shell echo $(PYTHON_VERSION) | cut -d. -f1,2)
|
||||||
# Change to 'uv' when ready.
|
# Change to 'uv' when ready.
|
||||||
RUNNER ?= poetry
|
RUNNER ?= poetry
|
||||||
|
|
||||||
|
export PYTHON_VERSION
|
||||||
|
export PYTHON_VERSION_SHORT
|
||||||
export RUNNER
|
export RUNNER
|
||||||
|
export IMAGE_NAME
|
||||||
|
|
||||||
# --- VARIABLES ---
|
# --- VARIABLES ---
|
||||||
CORE_DIR = brain
|
CORE_DIR = brain
|
||||||
@@ -20,7 +26,12 @@ INSTALL_CMD = $(if $(filter uv,$(RUNNER)),sync,install)
|
|||||||
ARGS = $(filter-out $@,$(MAKECMDGOALS))
|
ARGS = $(filter-out $@,$(MAKECMDGOALS))
|
||||||
BUMP_CMD = cd $(CORE_DIR) && $(RUNNER) run bump-my-version bump
|
BUMP_CMD = cd $(CORE_DIR) && $(RUNNER) run bump-my-version bump
|
||||||
COMPOSE_CMD = docker-compose
|
COMPOSE_CMD = docker-compose
|
||||||
DOCKER_CMD = cd $(CORE_DIR) && docker build --build-arg RUNNER=$(RUNNER) -t $(IMAGE_NAME):latest .
|
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_ADD = cd $(CORE_DIR) && $(RUNNER) add
|
||||||
RUNNER_HOOKS = cd $(CORE_DIR) && $(RUNNER) run pre-commit install -c ../.pre-commit-config.yaml
|
RUNNER_HOOKS = cd $(CORE_DIR) && $(RUNNER) run pre-commit install -c ../.pre-commit-config.yaml
|
||||||
@@ -35,7 +46,7 @@ T = \033[36m
|
|||||||
R = \033[0m
|
R = \033[0m
|
||||||
|
|
||||||
# --- TARGETS ---
|
# --- TARGETS ---
|
||||||
.PHONY: add build check-docker check-runner clean coverage down format help init-env install install-hooks lint logs major minor patch prune ps restart run shell test up update _check_branch
|
.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
|
# Catch-all for args
|
||||||
%:
|
%:
|
||||||
@@ -50,6 +61,17 @@ build: check-docker
|
|||||||
$(DOCKER_CMD)
|
$(DOCKER_CMD)
|
||||||
@echo "✅ Image $(IMAGE_NAME):latest ready."
|
@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:
|
check-docker:
|
||||||
@command -v docker >/dev/null 2>&1 || { echo "$(R)❌ Docker not installed$(R)"; exit 1; }
|
@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; }
|
@docker info >/dev/null 2>&1 || { echo "$(R)❌ Docker daemon not running$(R)"; exit 1; }
|
||||||
@@ -87,12 +109,13 @@ help:
|
|||||||
@echo "$(G)Setup:$(R)"
|
@echo "$(G)Setup:$(R)"
|
||||||
@echo " $(T)check-docker $(R) Verify Docker is installed and running."
|
@echo " $(T)check-docker $(R) Verify Docker is installed and running."
|
||||||
@echo " $(T)check-runner $(R) Verify package manager ($(RUNNER))."
|
@echo " $(T)check-runner $(R) Verify package manager ($(RUNNER))."
|
||||||
@echo " $(T)init-env $(R) Create .env from .env.example with generated secrets."
|
@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 $(R) Install ALL dependencies (Prod + Dev)."
|
||||||
@echo " $(T)install-hooks $(R) Install git pre-commit hooks."
|
@echo " $(T)install-hooks $(R) Install git pre-commit hooks."
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "$(G)Docker:$(R)"
|
@echo "$(G)Docker:$(R)"
|
||||||
@echo " $(T)build $(R) Build the docker image."
|
@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)down $(R) Stop and remove containers."
|
||||||
@echo " $(T)logs $(R) Follow logs."
|
@echo " $(T)logs $(R) Follow logs."
|
||||||
@echo " $(T)prune $(R) Clean Docker system."
|
@echo " $(T)prune $(R) Clean Docker system."
|
||||||
@@ -107,13 +130,13 @@ help:
|
|||||||
@echo " $(T)coverage $(R) Run tests with coverage."
|
@echo " $(T)coverage $(R) Run tests with coverage."
|
||||||
@echo " $(T)format $(R) Format code (Ruff)."
|
@echo " $(T)format $(R) Format code (Ruff)."
|
||||||
@echo " $(T)lint $(R) Lint code without fixing."
|
@echo " $(T)lint $(R) Lint code without fixing."
|
||||||
@echo " $(T)test ... $(R) Run tests."
|
@echo " $(T)test ... $(R) Run tests (local with $(RUNNER))."
|
||||||
@echo " $(T)update $(R) Update dependencies."
|
@echo " $(T)update $(R) Update dependencies."
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "$(G)Versioning:$(R)"
|
@echo "$(G)Versioning:$(R)"
|
||||||
@echo " $(T)major/minor/patch $(R) Bump version."
|
@echo " $(T)major/minor/patch $(R) Bump version."
|
||||||
|
|
||||||
init-env:
|
init-dotenv:
|
||||||
@echo "$(T)🔑 Initializing .env file...$(R)"
|
@echo "$(T)🔑 Initializing .env file...$(R)"
|
||||||
@if [ -f .env ]; then \
|
@if [ -f .env ]; then \
|
||||||
echo "$(R)⚠️ .env already exists. Skipping.$(R)"; \
|
echo "$(R)⚠️ .env already exists. Skipping.$(R)"; \
|
||||||
@@ -175,7 +198,7 @@ patch: _check_branch
|
|||||||
|
|
||||||
prune: check-docker
|
prune: check-docker
|
||||||
@echo "$(T)🗑️ Pruning Docker resources...$(R)"
|
@echo "$(T)🗑️ Pruning Docker resources...$(R)"
|
||||||
docker system prune -af --volumes
|
docker system prune -af
|
||||||
@echo "✅ Docker cleaned."
|
@echo "✅ Docker cleaned."
|
||||||
|
|
||||||
ps: check-docker
|
ps: check-docker
|
||||||
@@ -196,7 +219,7 @@ shell: check-docker
|
|||||||
|
|
||||||
test: check-runner
|
test: check-runner
|
||||||
@echo "$(T)🧪 Running tests...$(R)"
|
@echo "$(T)🧪 Running tests...$(R)"
|
||||||
$(RUNNER_RUN) pytest -n auto --dist=loadscope $(ARGS)
|
$(RUNNER_RUN) pytest $(ARGS)
|
||||||
|
|
||||||
up: check-docker
|
up: check-docker
|
||||||
@echo "$(T)🚀 Starting Agent Media...$(R)"
|
@echo "$(T)🚀 Starting Agent Media...$(R)"
|
||||||
@@ -213,3 +236,14 @@ _check_branch:
|
|||||||
if [ "$$curr" != "main" ]; then \
|
if [ "$$curr" != "main" ]; then \
|
||||||
echo "❌ Error: not on the main branch"; exit 1; \
|
echo "❌ Error: not on the main branch"; exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
_ci-image-name:
|
||||||
|
@echo "IMAGE_NAME=$(IMAGE_NAME)"
|
||||||
|
|
||||||
|
_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]
|
[tool.bumpversion]
|
||||||
current_version = "0.1.1"
|
current_version = "0.1.2"
|
||||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||||
serialize = ["{major}.{minor}.{patch}"]
|
serialize = ["{major}.{minor}.{patch}"]
|
||||||
search = "{current_version}"
|
search = "{current_version}"
|
||||||
|
|||||||
+21
-13
@@ -8,6 +8,9 @@ ARG RUNNER
|
|||||||
# ===========================================
|
# ===========================================
|
||||||
FROM python:${PYTHON_VERSION}-slim-bookworm as builder
|
FROM python:${PYTHON_VERSION}-slim-bookworm as builder
|
||||||
|
|
||||||
|
# Re-declare ARGs after FROM to make them available in this stage
|
||||||
|
ARG RUNNER
|
||||||
|
|
||||||
# STFU - No need - Write logs asap
|
# STFU - No need - Write logs asap
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
@@ -26,7 +29,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
|
|
||||||
# Copy dependency files
|
# Copy dependency files
|
||||||
COPY pyproject.toml poetry.lock* uv.lock* Makefile ./
|
COPY brain/pyproject.toml brain/poetry.lock* brain/uv.lock* Makefile ./
|
||||||
|
|
||||||
# Install dependencies as root (to avoid permission issues with system packages)
|
# Install dependencies as root (to avoid permission issues with system packages)
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
@@ -43,6 +46,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||||||
# Stage 2: Testing
|
# Stage 2: Testing
|
||||||
# ===========================================
|
# ===========================================
|
||||||
FROM builder as test
|
FROM builder as test
|
||||||
|
|
||||||
|
ARG RUNNER
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
--mount=type=cache,target=/root/.cache/pypoetry \
|
--mount=type=cache,target=/root/.cache/pypoetry \
|
||||||
--mount=type=cache,target=/root/.cache/uv \
|
--mount=type=cache,target=/root/.cache/uv \
|
||||||
@@ -52,18 +58,20 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||||||
uv pip install --system -e .[dev]; \
|
uv pip install --system -e .[dev]; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COPY agent/ ./agent/
|
COPY brain/agent/ ./agent/
|
||||||
COPY application/ ./application/
|
COPY brain/application/ ./application/
|
||||||
COPY domain/ ./domain/
|
COPY brain/domain/ ./domain/
|
||||||
COPY infrastructure/ ./infrastructure/
|
COPY brain/infrastructure/ ./infrastructure/
|
||||||
COPY tests/ ./tests/
|
COPY brain/tests/ ./tests/
|
||||||
COPY app.py .
|
COPY brain/app.py .
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Stage 3: Runtime
|
# Stage 3: Runtime
|
||||||
# ===========================================
|
# ===========================================
|
||||||
FROM python:${PYTHON_VERSION}-slim-bookworm as runtime
|
FROM python:${PYTHON_VERSION}-slim-bookworm as runtime
|
||||||
|
|
||||||
|
ARG PYTHON_VERSION_SHORT
|
||||||
|
|
||||||
ENV LLM_PROVIDER=deepseek \
|
ENV LLM_PROVIDER=deepseek \
|
||||||
MEMORY_STORAGE_DIR=/data/memory \
|
MEMORY_STORAGE_DIR=/data/memory \
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
@@ -90,15 +98,15 @@ USER appuser
|
|||||||
WORKDIR /home/appuser/app
|
WORKDIR /home/appuser/app
|
||||||
|
|
||||||
# Copy Python packages from builder stage
|
# Copy Python packages from builder stage
|
||||||
COPY --from=builder /usr/local/lib/${PYTHON_VERSION_SHORT}/site-packages /usr/local/lib/${PYTHON_VERSION_SHORT}/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 --from=builder /usr/local/bin /usr/local/bin
|
||||||
|
|
||||||
# Copy application code (already owned by appuser)
|
# Copy application code (already owned by appuser)
|
||||||
COPY --chown=appuser:appuser agent/ ./agent/
|
COPY --chown=appuser:appuser brain/agent/ ./agent/
|
||||||
COPY --chown=appuser:appuser application/ ./application/
|
COPY --chown=appuser:appuser brain/application/ ./application/
|
||||||
COPY --chown=appuser:appuser domain/ ./domain/
|
COPY --chown=appuser:appuser brain/domain/ ./domain/
|
||||||
COPY --chown=appuser:appuser infrastructure/ ./infrastructure/
|
COPY --chown=appuser:appuser brain/infrastructure/ ./infrastructure/
|
||||||
COPY --chown=appuser:appuser app.py .
|
COPY --chown=appuser:appuser brain/app.py .
|
||||||
|
|
||||||
# Create volumes for persistent data
|
# Create volumes for persistent data
|
||||||
VOLUME ["/data/memory", "/data/logs"]
|
VOLUME ["/data/memory", "/data/logs"]
|
||||||
|
|||||||
Generated
+1
-1
@@ -1220,4 +1220,4 @@ files = [
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "6204ac4c938e73f59f5bffef08e8e3cdbbc5c307a693578b1183d6140d4e8f31"
|
content-hash = "b6cec0647accef2c235cededb06cab49f30033fb5e5ce1f6b589a4da5d2a2d8d"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "agent-media"
|
name = "agent-media"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "AI agent for managing a local media library"
|
description = "AI agent for managing a local media library"
|
||||||
authors = ["Francwa <francois.hodiaumont@gmail.com>"]
|
authors = ["Francwa <francois.hodiaumont@gmail.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Reference in New Issue
Block a user