anicove2 / Dockerfile
mwask's picture
Update Dockerfile
89c3d99 verified
Raw
History Blame Contribute Delete
1.08 kB
# Use Python 3.11 slim image for smaller size
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PORT=7860
# Set working directory
WORKDIR /app
# Install system dependencies (ffmpeg for yt-dlp, curl for healthchecks)
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Copy application code
COPY . .
# Expose port (documentation; HF handles actual port mapping)
EXPOSE 7860
# Health check (uses PORT env var with fallback)
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Run the application
# Assumes run.py reads PORT from environment and binds to 0.0.0.0
CMD ["python", "run.py"]