File size: 2,214 Bytes
ccaa4a4
a8504d4
 
ccaa4a4
a8504d4
 
5e26283
a8504d4
 
 
 
 
 
5e26283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ccaa4a4
 
a8504d4
144cd03
ccaa4a4
a8504d4
5e26283
 
 
 
 
a8504d4
5e26283
 
e425c50
5e26283
 
a8504d4
ccaa4a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Use Python 3.9 slim image
FROM python:3.9-slim

# Set the working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

# Set HOME so Streamlit doesn't try to write to /
ENV HOME=/app

# Create .streamlit directory so Streamlit can store config
RUN mkdir -p /app/.streamlit

# Configure Streamlit (disable CORS, telemetry, etc.)
RUN echo "\
[general]\n\
email = \"\"\n\
\n\
[server]\n\
headless = true\n\
enableCORS = false\n\
\n\
[browser]\n\
gatherUsageStats = false\n\
" > /app/.streamlit/config.toml

# Copy requirements
COPY requirements.txt .

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

# Copy application files
COPY src/ ./src/

# Expose default Streamlit port
EXPOSE 8501

# Healthcheck for Hugging Face Spaces
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1

# Run Streamlit, using PORT from environment if provided, else default to 8501
CMD ["sh", "-c", "streamlit run src/streamlit_app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]

# ##################################################################################################
# FROM python:3.9-slim

# WORKDIR /app

# # Install required packages
# RUN apt-get update && apt-get install -y \
#     build-essential \
#     curl \
#     git \
#     && rm -rf /var/lib/apt/lists/*

# # Set HOME so Streamlit doesn't try to write to /
# ENV HOME=/app

# # Create .streamlit directory so Streamlit can store config
# RUN mkdir -p /app/.streamlit

# # Optional: Disable telemetry collection if desired
# RUN echo "\
# [general]\n\
# email = \"\"\n\
# \n\
# [server]\n\
# headless = true\n\
# enableCORS = false\n\
# \n\
# [browser]\n\
# gatherUsageStats = false\n\
# " > /app/.streamlit/config.toml

# # Copy files
# COPY requirements.txt ./
# COPY src/ ./src/

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

# EXPOSE 8501

# HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1

# ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]