h / Dockerfile
Xlnk's picture
Upload 8 files
f751cec verified
raw
history blame contribute delete
882 Bytes
# Use official Python slim image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Create non-root user for security (required by HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory for user
WORKDIR $HOME/app
# Copy requirements first for better caching
COPY --chown=user requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt gunicorn
# Copy application code
COPY --chown=user . .
# Create uploads directory with proper permissions
RUN mkdir -p uploads && chmod 755 uploads
# Expose port 7860 (Hugging Face Spaces default)
EXPOSE 7860
# Run with gunicorn for production
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "2", "app:app"]