Skip to content

Commit 33a7fb0

Browse files
fix(graph): neo4j query str format
1 parent 30470dc commit 33a7fb0

File tree

3 files changed

+89
-2
lines changed

3 files changed

+89
-2
lines changed

Dockerfile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Multi-stage build for brainapi2
2+
FROM python:3.11-slim AS builder
3+
4+
ARG BUILD_DATE
5+
ARG BUILD_SHA
6+
ARG CACHE_BUST
7+
8+
# Set environment variables
9+
ENV PYTHONUNBUFFERED=1 \
10+
PYTHONDONTWRITEBYTECODE=1 \
11+
PIP_NO_CACHE_DIR=1 \
12+
PIP_DISABLE_PIP_VERSION_CHECK=1
13+
14+
# Install system dependencies
15+
RUN apt-get update && apt-get install -y \
16+
build-essential \
17+
curl \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Install Poetry
21+
RUN pip install poetry==1.8.3
22+
23+
# Configure Poetry
24+
ENV POETRY_NO_INTERACTION=1 \
25+
POETRY_VENV_IN_PROJECT=1 \
26+
POETRY_CACHE_DIR=/tmp/poetry_cache \
27+
POETRY_VENV_PATH=/app/.venv
28+
29+
# Set work directory
30+
WORKDIR /app
31+
32+
# Copy Poetry files
33+
COPY pyproject.toml poetry.lock ./
34+
35+
# Install dependencies
36+
RUN poetry config virtualenvs.in-project true && \
37+
poetry lock && poetry install --no-root --sync && rm -rf $POETRY_CACHE_DIR
38+
39+
# Production stage
40+
FROM python:3.11-slim AS production
41+
42+
ARG BUILD_DATE
43+
ARG BUILD_SHA
44+
ARG CACHE_BUST
45+
46+
LABEL build_date="${BUILD_DATE}" \
47+
build_sha="${BUILD_SHA}" \
48+
cache_bust="${CACHE_BUST}"
49+
50+
# Set environment variables
51+
ENV PYTHONUNBUFFERED=1 \
52+
PYTHONDONTWRITEBYTECODE=1 \
53+
PATH="/app/.venv/bin:$PATH"
54+
55+
# Install runtime dependencies
56+
RUN apt-get update && apt-get install -y \
57+
curl \
58+
&& rm -rf /var/lib/apt/lists/*
59+
60+
# Create non-root user
61+
RUN groupadd -r appuser && useradd -r -g appuser appuser
62+
63+
# Set work directory
64+
WORKDIR /app
65+
66+
# Copy virtual environment from builder stage
67+
COPY --from=builder /app/.venv /app/.venv
68+
69+
# Copy application code
70+
COPY src/ ./src/
71+
72+
# Change ownership to non-root user
73+
RUN chown -R appuser:appuser /app
74+
USER appuser
75+
76+
# Switch to non-root user
77+
USER root
78+
79+
# Expose port
80+
EXPOSE 8000
81+
82+
# Health check
83+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
84+
CMD curl -f http://localhost:8000/docs || exit 1
85+
86+
# Default command
87+
CMD ["/app/.venv/bin/python", "-m", "uvicorn", "src.services.api.app:app", "--host", "0.0.0.0", "--port", "8000"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "brainapi2"
3-
version = "1.5.1"
3+
version = "1.5.1-dev"
44
description = "Version 1.x.x of the BrainAPI memory layer."
55
authors = [
66
{name = "Christian",email = "alch.infoemail@gmail.com"}

src/lib/neo4j/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def search_relationships(
720720
SKIP {skip}
721721
LIMIT {limit}
722722
"""
723-
cypher_count = """
723+
cypher_count = f"""
724724
MATCH (n)-[r]-(m)
725725
{"WHERE " + " AND ".join(filters) if filters else ""}
726726
RETURN count(r) AS total

0 commit comments

Comments
 (0)