-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.python
More file actions
51 lines (39 loc) · 1.76 KB
/
Dockerfile.python
File metadata and controls
51 lines (39 loc) · 1.76 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
# Dockerfile.python — Shared Python base image for SRFM Lab services
# Multi-stage: builder installs deps, final image is slim.
#
# All Python services (bridge, autonomous-loop, live-trader) use this image.
# Build context is always the repo root so requirements.txt is available.
# ── Stage 1: builder ──────────────────────────────────────────────────────────
FROM python:3.11-slim AS builder
WORKDIR /build
# System deps needed to compile some Python packages (numpy, polars, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
libffi-dev \
libssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: final ────────────────────────────────────────────────────────────
FROM python:3.11-slim AS final
LABEL org.opencontainers.image.title="srfm-lab-python"
LABEL org.opencontainers.image.description="SRFM Lab shared Python runtime"
# Runtime system libs only
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /install /usr/local
WORKDIR /app
# Copy entire repo (docker-compose will override specific dirs via volume mounts)
COPY . .
# Non-root user for security
RUN useradd -m -u 1000 srfm
USER srfm
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app