FastApi-GeminiApi/Dockerfile
2025-11-16 18:30:04 +03:30

43 lines
1.1 KiB
Docker

# Use Python 3.11 slim image as base
FROM python:3.11-slim
# ---- System setup ----
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
FFMPEG_BIN=/usr/bin/ffmpeg \
FFPROBE_BIN=/usr/bin/ffprobe
# Set working directory
WORKDIR /app
# Install system dependencies (ffmpeg + curl for healthcheck, build tools for pip)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt ./requirements.txt
# Install Python dependencies
RUN python -m pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Expose port
EXPOSE 8000
# Health check (uses curl we installed above)
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -fsS http://localhost:8000/health || exit 1
# Run the application
# For dev: keep --reload + volume mount
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]