File size: 741 Bytes
59f2666
 
 
 
 
 
 
 
 
 
 
 
 
 
1cebeaf
 
59f2666
 
 
1cebeaf
59f2666
 
 
 
 
 
 
 
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
28
# Use a slim Python image for smaller size
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Create directories and set permissions as root
RUN mkdir -p static/uploads logs data && \
    chmod -R 777 static/uploads logs data

# Create a non-root user and switch to it
RUN useradd -m appuser && \
    chown -R appuser:appuser static/uploads logs data

USER appuser

# Set environment variable for port (Hugging Face default)
ENV PORT=7860

# Run Gunicorn with the Flask app
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "0", "app:app"]