From ff4cc14a46e2b3a014e45dd3be2d19eb544ccac4 Mon Sep 17 00:00:00 2001 From: Saravana Achu Mac Date: Sun, 15 Feb 2026 15:10:08 -0800 Subject: [PATCH] fix(extraction-service): run python sidecar on railway --- services/extraction-service/Dockerfile | 29 ++++++++++---------- services/extraction-service/supervisord.conf | 4 +-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/services/extraction-service/Dockerfile b/services/extraction-service/Dockerfile index cdacf7bc..d28c05a6 100644 --- a/services/extraction-service/Dockerfile +++ b/services/extraction-service/Dockerfile @@ -2,7 +2,7 @@ # Multi-stage: Node.js build + Python sidecar + supervisord runtime # ── Stage 1: Node.js build ─────────────────────────────────────── -FROM node:22-alpine AS ts-builder +FROM node:22-slim AS ts-builder RUN npm install -g pnpm@10 WORKDIR /app @@ -39,28 +39,27 @@ RUN pnpm -r --filter @lysnrai/extraction-service... build # Deploy to isolated directory (production deps only) RUN pnpm --filter @lysnrai/extraction-service deploy --legacy /app/deploy -# ── Stage 2: Python sidecar build ──────────────────────────────── -FROM python:3.12-slim AS py-builder -WORKDIR /sidecar +# ── Stage 2: Production runtime (Node.js + Python sidecar) ─────── +FROM node:22-slim -COPY services/extraction-service/python/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN apt-get update \ + && apt-get install -y --no-install-recommends python3 python3-venv supervisor \ + && rm -rf /var/lib/apt/lists/* -COPY services/extraction-service/python/src/ src/ - -# ── Stage 3: Production runtime ────────────────────────────────── -FROM node:22-alpine -RUN apk add --no-cache python3 py3-pip supervisor +# Create an isolated venv for sidecar deps (avoids Debian PEP 668 restrictions). +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" WORKDIR /app # Copy Node.js service COPY --from=ts-builder /app/deploy ./ -# Copy Python sidecar + installed packages -COPY --from=py-builder /usr/local/lib/python3.12/site-packages /usr/lib/python3/dist-packages -COPY --from=py-builder /usr/local/bin/uvicorn /usr/local/bin/uvicorn -COPY --from=py-builder /sidecar/src /app/python/src +# Python sidecar (installed in the same OS/Python runtime to avoid ABI issues) +WORKDIR /app/python +COPY services/extraction-service/python/requirements.txt ./requirements.txt +RUN pip install --no-cache-dir -r requirements.txt +COPY services/extraction-service/python/src ./src # Copy supervisord config COPY services/extraction-service/supervisord.conf /etc/supervisor/conf.d/extraction.conf diff --git a/services/extraction-service/supervisord.conf b/services/extraction-service/supervisord.conf index 89a36513..71a60004 100644 --- a/services/extraction-service/supervisord.conf +++ b/services/extraction-service/supervisord.conf @@ -13,10 +13,10 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 -environment=NODE_ENV="production",PORT="4005" +environment=NODE_ENV="production" [program:python-sidecar] -command=uvicorn src.app:app --host 0.0.0.0 --port 4006 --workers 1 +command=python3 -m uvicorn src.app:app --host 0.0.0.0 --port 4006 --workers 1 directory=/app/python autostart=true autorestart=true