infra!: added CI/CD pipeline and made various improvements to Makefile and Dockerfile
This commit is contained in:
+38
-9
@@ -1,12 +1,16 @@
|
||||
# Dockerfile for Agent Media
|
||||
# Multi-stage build for smaller image size
|
||||
ARG PYTHON_VERSION=3.14.2
|
||||
ARG PYTHON_VERSION
|
||||
ARG PYTHON_VERSION_SHORT
|
||||
ARG RUNNER
|
||||
# ===========================================
|
||||
# Stage 1: 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
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
@@ -25,7 +29,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
WORKDIR /tmp
|
||||
|
||||
# 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)
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
@@ -39,10 +43,35 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
fi
|
||||
|
||||
# ===========================================
|
||||
# Stage 2: Runtime
|
||||
# Stage 2: Testing
|
||||
# ===========================================
|
||||
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 \
|
||||
@@ -69,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"]
|
||||
|
||||
Generated
+1
-1
@@ -1220,4 +1220,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "6204ac4c938e73f59f5bffef08e8e3cdbbc5c307a693578b1183d6140d4e8f31"
|
||||
content-hash = "b6cec0647accef2c235cededb06cab49f30033fb5e5ce1f6b589a4da5d2a2d8d"
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user