File size: 1,199 Bytes
6a2e2f2
 
 
 
6095b30
6a2e2f2
 
 
 
 
391d19c
 
6a2e2f2
 
6095b30
f2dfe5d
6a2e2f2
f2dfe5d
6a2e2f2
6095b30
618a4db
 
6095b30
f2dfe5d
 
 
618a4db
6095b30
618a4db
6095b30
f2dfe5d
 
 
 
 
6095b30
 
f2dfe5d
 
 
 
 
6095b30
 
6a2e2f2
6095b30
 
6a2e2f2
6095b30
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM python:3.9-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy project files
COPY requirements.txt ./requirements.txt
COPY src/ ./src/
COPY best.pt ./src/best.pt

# Install Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt

# Set environment variables for Streamlit and Ultralytics
ENV HOME=/app
ENV XDG_CONFIG_HOME=/app/.config
ENV STREAMLIT_HOME=/app/.streamlit
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
ENV YOLO_CONFIG_DIR=/tmp

# Create and configure Streamlit settings
RUN mkdir -p /app/.streamlit && \
    echo "\
[server]\n\
headless = true\n\
enableCORS = false\n\
enableXsrfProtection = false\n\
port = 7860\n\
\n\
[browser]\n\
gatherUsageStats = false\n\
" > /app/.streamlit/config.toml

# Expose port expected by Hugging Face
EXPOSE 7860

# Healthcheck (optional)
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1

# Run the Streamlit app
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]