BrainAPI is a knowledge graph–powered AI memory layer that transforms unstructured data into structured knowledge, enabling intelligent search, recommendations, and contextual memory for AI agents and applications.
Python ai-agentsai-memoryknowledge-graphknowledge-managementknowledge-representationreccomendation-system
build(Dockerfile): removed installations and migrated to runtime
Christianbc279b4fbfb1
diff --git a/Dockerfile b/Dockerfileindex f693ee3..13a4d4c 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,78 +1,42 @@-# Multi-stage build for brainapi2-FROM python:3.11-slim AS builder+FROM python:3.11-slimARG BUILD_DATEARG BUILD_SHA-ARG CACHE_BUST--ENV PYTHONUNBUFFERED=1 \- PYTHONDONTWRITEBYTECODE=1 \- PIP_NO_CACHE_DIR=1 \- PIP_DISABLE_PIP_VERSION_CHECK=1--RUN apt-get update && apt-get install -y \- build-essential \- curl \- && rm -rf /var/lib/apt/lists/*--RUN pip install poetry==1.8.3--ENV POETRY_NO_INTERACTION=1 \- POETRY_VENV_IN_PROJECT=1 \- POETRY_CACHE_DIR=/tmp/poetry_cache \- POETRY_VENV_PATH=/app/.venv--WORKDIR /app--COPY pyproject.toml poetry.lock ./--RUN poetry config virtualenvs.in-project true && \- poetry lock --no-update && \- poetry install --no-root --sync && \- rm -rf $POETRY_CACHE_DIR && \- .venv/bin/pip uninstall -y torch && \- .venv/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir--RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')"--# Production stage-FROM python:3.11-slim AS production--ARG BUILD_DATE-ARG BUILD_SHA-ARG CACHE_BUSTLABEL build_date="${BUILD_DATE}" \- build_sha="${BUILD_SHA}" \- cache_bust="${CACHE_BUST}"+ build_sha="${BUILD_SHA}"ENV PYTHONUNBUFFERED=1 \PYTHONDONTWRITEBYTECODE=1 \- PATH="/app/.venv/bin:$PATH"+ PATH="/app/.venv/bin:$PATH" \+ TRANSFORMERS_CACHE=/app/.cache \+ SENTENCE_TRANSFORMERS_HOME=/app/.cache \+ POETRY_NO_INTERACTION=1 \+ POETRY_VENV_IN_PROJECT=1RUN apt-get update && apt-get install -y \+ build-essential \curl \&& rm -rf /var/lib/apt/lists/* && \+ pip install poetry==1.8.3 && \groupadd -r appuser && useradd -r -g appuser appuserWORKDIR /app-COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv-+COPY --chown=appuser:appuser pyproject.toml poetry.lock ./COPY --chown=appuser:appuser src/ ./src/+COPY --chown=appuser:appuser entrypoint.sh ./-USER appuser+RUN chmod +x /app/entrypoint.sh && \+ mkdir -p /app/.venv /app/.cache && \+ chown -R appuser:appuser /app-RUN mkdir -p /app/.cache && chown -R appuser:appuser /app/.cache-ENV TRANSFORMERS_CACHE=/app/.cache-ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache+USER appuser-# Expose portEXPOSE 8000-# Health checkHEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \CMD curl -f http://localhost:8000/docs || exit 1-# Default command-CMD ["/app/.venv/bin/python", "-m", "uvicorn", "src.services.api.app:app", "--host", "0.0.0.0", "--port", "8000", "--access-log", "--log-level", "info"]+ENTRYPOINT ["/app/entrypoint.sh"]+CMD ["-m", "uvicorn", "src.services.api.app:app", "--host", "0.0.0.0", "--port", "8000", "--access-log", "--log-level", "info"]diff --git a/entrypoint.sh b/entrypoint.shnew file mode 100644index 0000000..41dd315--- /dev/null+++ b/entrypoint.sh@@ -0,0 +1,17 @@+#!/bin/bash+set -e++if [ ! -d "/app/.venv" ] || [ ! -f "/app/.venv/bin/python" ]; then+ echo "Installing dependencies..."+ poetry config virtualenvs.in-project true+ poetry install --no-root --sync+ .venv/bin/pip uninstall -y torch+ .venv/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir+fi++echo "Checking for sentence-transformers model..."+/app/.venv/bin/python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')"+echo "Ready."++exec /app/.venv/bin/python "$@"+