mgbam commited on
Commit
2321094
·
verified ·
1 Parent(s): 68d515f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -24
Dockerfile CHANGED
@@ -1,32 +1,36 @@
 
1
  FROM python:3.10-slim
2
 
3
- # Ensure Streamlit writes to a writable directory
4
- ENV HOME=/app
5
- ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
6
-
7
- WORKDIR /app
8
-
9
- # Install production dependencies only
 
 
 
 
 
 
 
 
 
 
 
 
10
  COPY requirements.txt .
11
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy codebase
14
  COPY . .
15
 
16
- # Ensure config folder exists with correct permissions
17
- RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
18
-
19
- # Add minimal Streamlit config
20
- RUN echo "\
21
- [server]\n\
22
- headless = true\n\
23
- port = 8501\n\
24
- address = \"0.0.0.0\"\n\
25
- enableCORS = false\n\
26
- enableXsrfProtection = false\n\
27
- " > /app/.streamlit/config.toml
28
 
29
- EXPOSE 8501
 
30
 
31
- # Shell form CMD ensures log output compatibility on Spaces
32
- CMD streamlit run app.py --server.port=8501 --server.address=0.0.0.0
 
1
+ # Use an official lightweight Python image
2
  FROM python:3.10-slim
3
 
4
+ # Prevent Python from writing .pyc files and enable unbuffered output
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1 \
7
+ PORT=7860 \
8
+ STREAMLIT_SERVER_PORT=7860 \
9
+ STREAMLIT_SERVER_HEADLESS=true \
10
+ STREAMLIT_SERVER_ENABLECORS=false \
11
+ STREAMLIT_SERVER_ENABLEWEBRTC=false
12
+
13
+ # Set the working directory
14
+ WORKDIR /code
15
+
16
+ # Install OS-level dependencies (if needed, add more as required)
17
+ RUN apt-get update && \
18
+ apt-get install -y --no-install-recommends \
19
+ build-essential \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Install Python dependencies first for efficient caching
23
  COPY requirements.txt .
24
+ RUN pip install --upgrade pip && pip install -r requirements.txt
25
 
26
+ # Copy the rest of your project files
27
  COPY . .
28
 
29
+ # Expose the Streamlit port
30
+ EXPOSE 7860
 
 
 
 
 
 
 
 
 
 
31
 
32
+ # (Optional) If you want to display Streamlit logs in real-time, you can add:
33
+ ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE="poll"
34
 
35
+ # Start the app
36
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]