43 lines
1.4 KiB
Docker
43 lines
1.4 KiB
Docker
# --- STAGE 1: Builder ---
|
|
FROM python:3.11-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies needed for building C-extensions
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install dependencies system-wide
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
# VERIFICATION STEP: Ensure uvicorn is installed and found
|
|
RUN which uvicorn || (echo "ERROR: uvicorn not found after install!" && exit 1)
|
|
|
|
# --- STAGE 2: Final Runtime ---
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install curl for healthcheck
|
|
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy system-wide installed packages from builder
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
# Ensure /usr/local/bin (where pip installs executables by default) is in PATH
|
|
ENV PATH=/usr/local/bin:$PATH
|
|
|
|
# Copy source code explicitly from their locations relative to the build context (which will be the project root)
|
|
COPY worker.py .
|
|
COPY webhook_app.py .
|
|
COPY queue_manager.py .
|
|
COPY config.py .
|
|
COPY superoffice_client.py .
|
|
|
|
# Expose port for Webhook
|
|
EXPOSE 8000
|
|
|
|
# Start both worker and webhook directly within the CMD, using absolute path for uvicorn
|
|
CMD ["/bin/bash", "-c", "python3 worker.py & /usr/local/bin/uvicorn webhook_app:app --host 0.0.0.0 --port 8000"]
|