Spaces:
Running
Running
File size: 905 Bytes
51c43d6 b53345f 51c43d6 3d37592 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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
|