fix(extraction-service): run python sidecar on railway

This commit is contained in:
Saravana Achu Mac 2026-02-15 15:10:08 -08:00
parent 3464d35efe
commit ff4cc14a46
2 changed files with 16 additions and 17 deletions

View File

@ -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

View File

@ -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