home23 / Dockerfile
Hadiil's picture
Update Dockerfile
10a0c25 verified
# Use official Python image
FROM python:3.10-slim
# Environment variables
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/app/cache
ENV UPLOAD_DIR=/app/uploads
ENV PORT=7860
# Create directories
RUN mkdir -p /app/cache /app/uploads /app/static && \
chmod -R 777 /app
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Pythonnnn dependencies
RUN pip install --no-cache-dir -U pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY . .
# Expose the port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]