File size: 848 Bytes
1082fc8
7fcff4a
1082fc8
a07581b
f69f2cb
1082fc8
7fcff4a
1082fc8
 
7fcff4a
 
 
1082fc8
 
f69f2cb
 
 
5764d7a
1082fc8
 
f69f2cb
 
 
1082fc8
a07581b
1082fc8
f69f2cb
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
# PV Defect Classifier — HuggingFace Spaces
FROM python:3.11-slim

# Run as non-root user (UID 1000) per container security best practices
RUN useradd -m -u 1000 user

WORKDIR /app

# Install dependencies (cache layer)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir gunicorn

# Copy application code (--chown avoids permission issues)
COPY --chown=user app.py .
COPY --chown=user templates/ templates/
COPY --chown=user models/ models/
COPY --chown=user test_images/ test_images/

# Switch to non-root user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Bind to container-configured application port 7860
# 1 worker = 1 model copy in memory; timeout 120s for cold start
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]