2025-09-18 19:51:47 +05:30
|
|
|
# Multi-stage Dockerfile
|
|
|
|
|
# Stage 1: Builder - Install Python dependencies
|
|
|
|
|
FROM python:3.12-slim AS builder
|
2025-09-09 14:37:32 +05:30
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-09-18 19:51:47 +05:30
|
|
|
# Install git in builder stage (needed for pip install from git)
|
2025-09-09 14:37:32 +05:30
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
git \
|
|
|
|
|
&& apt-get clean \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Copy and install requirements
|
|
|
|
|
COPY requirements.txt .
|
2025-09-11 19:08:17 +05:30
|
|
|
|
2025-09-18 19:51:47 +05:30
|
|
|
# Install dependencies to user directory for easy copying
|
|
|
|
|
RUN pip install --user --no-cache-dir -r requirements.txt && \
|
|
|
|
|
# Clean up pip cache after installation
|
|
|
|
|
rm -rf /root/.cache/pip
|
2025-09-09 14:37:32 +05:30
|
|
|
|
2025-09-11 19:08:17 +05:30
|
|
|
# Force reinstall of pipecat on every build (cache bust)
|
2025-09-18 19:51:47 +05:30
|
|
|
|
2025-09-11 19:08:17 +05:30
|
|
|
ARG CACHEBUST=1
|
2025-09-30 19:48:40 +05:30
|
|
|
RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@f88c8a0#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc]' && \
|
2025-09-18 19:51:47 +05:30
|
|
|
# Clean up pip cache after pipecat installation
|
|
|
|
|
rm -rf /root/.cache/pip
|
|
|
|
|
|
|
|
|
|
# Remove unnecessary Python cache files from installed packages
|
|
|
|
|
RUN find /root/.local -type f -name '*.pyc' -delete && \
|
|
|
|
|
find /root/.local -type d -name '__pycache__' -delete && \
|
|
|
|
|
find /root/.local -type f -name '*.pyo' -delete
|
|
|
|
|
|
|
|
|
|
# Stage 2: Runtime - Minimal image with only runtime dependencies
|
|
|
|
|
FROM python:3.12-slim AS runner
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Only install ffmpeg (runtime dependency)
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
|
ffmpeg \
|
|
|
|
|
&& apt-get clean \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Copy Python packages from builder stage
|
|
|
|
|
COPY --from=builder /root/.local /root/.local
|
|
|
|
|
|
|
|
|
|
# Make sure scripts in .local are available
|
|
|
|
|
ENV PATH=/root/.local/bin:$PATH
|
|
|
|
|
|
|
|
|
|
# Set Python to not generate .pyc files in runtime
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
# Unbuffered output for better container logging
|
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
2025-09-11 19:08:17 +05:30
|
|
|
|
2025-09-18 19:51:47 +05:30
|
|
|
# Copy application code
|
2025-09-09 14:37:32 +05:30
|
|
|
COPY . ./api
|
|
|
|
|
|
|
|
|
|
ENV PYTHONPATH=/app
|
|
|
|
|
|
|
|
|
|
# Expose the port FastAPI will run on
|
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
# Run the FastAPI app with uvicorn
|
|
|
|
|
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000"]
|