Files
whisper-api/docker/Dockerfile

67 lines
1.6 KiB
Docker

FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies with Python 3.12 from deadsnakes PPA
RUN apt-get update && apt-get install -y \
software-properties-common \
pkg-config \
&& add-apt-repository ppa:deadsnakes/ppa -y \
&& apt-get update \
&& apt-get install -y \
python3.12 \
python3.12-dev \
python3.12-venv \
ffmpeg \
libavformat-dev \
libavcodec-dev \
libavdevice-dev \
libavutil-dev \
libavfilter-dev \
libswscale-dev \
libswresample-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install pip for Python 3.12
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
# Set Python 3.12 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
RUN update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3 1
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy entrypoint script
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create necessary directories
RUN mkdir -p /app/models /app/data /app/uploads
# Copy application code
COPY src/ ./src/
# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run the application
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]