Spaces:
Running
Running
# Use Python 3.11 slim base image for smaller size | |
FROM python:3.11-slim | |
# Create non-root user for security | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
ENV FLASK_APP=app.py | |
ENV FLASK_ENV=production | |
# Set working directory for app | |
WORKDIR /app | |
# Copy requirements with correct ownership first for better layer caching | |
COPY --chown=user requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy application code with correct ownership (all files from current directory to container) | |
COPY --chown=user . . | |
# Run gunicorn server on port 7860 | |
# CMD ["uvicorn", "-b", "0.0.0.0:7860", "app:app"] # Format: gunicorn -b host:port module_name:app_instance | |
CMD gunicorn --bind 0.0.0.0:7860 app:app | |
# CMD ["uvicorn", "--log-level", "debug", "--bind", "0.0.0.0:7860", "app:app"] # Use 0.0.0.0 to bind to all interfaces | |