-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (43 loc) · 2.07 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (43 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# --- L9_META ---
# l9_schema: 1
# origin: l9-template
# engine: graph
# layer: [docker]
# tags: [L9_TEMPLATE, docker, dev]
# owner: platform
# status: active
# --- /L9_META ---
# ─────────────────────────────────────────────────────────────
# L9 Graph Cognitive Engine — Multi-stage Dockerfile
# Stage 1: deps — install Python packages
# Stage 2: runtime — slim image with only what we need
# ─────────────────────────────────────────────────────────────
# ── Stage 1: Dependencies ──────────────────────────────────
FROM python:3.12-slim AS deps
# git is required to resolve the git+https constellation-node-sdk dependency
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: Runtime ───────────────────────────────────────
FROM python:3.12-slim AS runtime
WORKDIR /app
# Copy installed packages from deps stage
COPY --from=deps /install /usr/local
# Copy application code
COPY engine/ /app/engine/
COPY domains/ /app/domains/
COPY chassis/ /app/chassis/
# Copy entrypoint
COPY scripts/entrypoint.sh /app/entrypoint.sh
# Make the entrypoint executable and create the non-root user in a single layer
RUN chmod +x /app/entrypoint.sh \
&& groupadd -r l9 && useradd -r -g l9 -d /app -s /sbin/nologin l9 \
&& chown -R l9:l9 /app
USER l9
EXPOSE 8000
# Health check
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD python -c "import httpx; r=httpx.get('http://localhost:8000/v1/health'); exit(0 if r.status_code==200 and r.json().get('ready', True) else 1)"
ENTRYPOINT ["/app/entrypoint.sh"]