Abs6187 commited on
Commit
b1cb267
·
verified ·
1 Parent(s): f47e727

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -26
Dockerfile CHANGED
@@ -1,38 +1,32 @@
1
- # Use a lightweight Python base image
2
- FROM python:3.9-slim
3
-
4
- # Optionally allow overriding port at build time
5
- ARG PORT=7860
6
- ENV PORT=${PORT}
7
 
8
  WORKDIR /app
9
 
10
- # Install system dependencies needed by many ML/AI and media libraries
11
  RUN apt-get update && apt-get install -y \
12
- ffmpeg \
13
- libgl1 \
14
- libglib2.0-0 \
15
- libsm6 \
16
- libxrender1 \
17
- libxext6 \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
- # Copy dependency files first to leverage Docker cache
21
- COPY requirements.txt .
22
- COPY packages.txt .
23
 
24
  # Install Python dependencies
25
- RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Copy application code
28
- COPY . .
 
 
29
 
30
- # Ensure your app uses the PORT environment variable
31
- EXPOSE ${PORT}
32
 
33
- # Healthcheck (adjust the path if your app uses a different one)
34
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
35
- CMD curl -f http://localhost:${PORT}/_stcore/health || exit 1
36
 
37
- # Run the application make sure your app or command respects $PORT
38
- CMD ["streamlit", "run", "app.py", "--server.port=${PORT}", "--server.address=0.0.0.0"]
 
1
+ FROM python:3.13.5-slim
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install OS-level dependencies if your app needs them (e.g. building wheels, git, curl)
6
  RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ git \
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy dependency spec and source code
13
+ COPY requirements.txt ./
14
+ COPY src/ ./src/
15
 
16
  # Install Python dependencies
17
+ RUN pip3 install --no-cache-dir -r requirements.txt
18
 
19
+ # (Optional) Set environment variables useful in HF Spaces / container environment
20
+ # Avoid Streamlit trying to write to root directories it might not have permission to.
21
+ ENV STREAMLIT_HOME=/tmp/.streamlit
22
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
23
 
24
+ # Expose the port used by Streamlit in HF (8501)
25
+ EXPOSE 8501
26
 
27
+ # Healthcheck: test whether Streamlit's health endpoint is alive
28
+ # But note: there are known issues with Streamlit health endpoint in some environments. :contentReference[oaicite:2]{index=2}
29
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
30
 
31
+ # Launch Streamlit app; bind to 0.0.0.0 so external connections work
32
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]