alidenewade commited on
Commit
b91b9b2
·
verified ·
1 Parent(s): 884be71

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -27
Dockerfile CHANGED
@@ -1,38 +1,31 @@
1
- # Use a slim Python base image
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # --- FIX FOR PERMISSION ERROR ---
8
- # Set the STREAMLIT_HOME environment variable to a writable directory.
9
- ENV STREAMLIT_HOME=/app/.streamlit
10
-
11
- # Explicitly create the directory.
12
- RUN mkdir -p $STREAMLIT_HOME
13
-
14
- # Copy the requirements file and application code first
15
- COPY requirements.txt ./requirements.txt
16
- COPY . .
17
-
18
- # Change ownership of the app directory to the default non-root user (often 'appuser' or uid 1000)
19
- # This is the key fix for permission errors on platforms like Hugging Face Spaces.
20
- RUN chown -R 1000:1000 /app
21
-
22
- # Install system dependencies that may be needed by the Python libraries
23
  RUN apt-get update && apt-get install -y \
24
  build-essential \
25
- libxrender1 \
26
- libxext6 \
 
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
- # Install the Python dependencies
30
- RUN pip install --no-cache-dir --upgrade pip && \
31
- pip install --no-cache-dir -r requirements.txt
32
 
33
- # Expose the port that Streamlit will run on (Hugging Face default is 7860)
 
 
 
 
 
 
34
  EXPOSE 7860
35
 
36
- # Command to run the Streamlit app
37
- # The --server.headless=true flag is recommended for containerized environments
38
- CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.headless=true"]
 
 
 
1
+ # Use Python 3.9 slim image as base
2
  FROM python:3.9-slim
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
+ curl \
11
+ software-properties-common \
12
+ git \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Copy requirements first to leverage Docker cache
16
+ COPY requirements.txt .
 
17
 
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Copy the application code
22
+ COPY . .
23
+
24
+ # Expose the port that Streamlit runs on
25
  EXPOSE 7860
26
 
27
+ # Add healthcheck
28
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
29
+
30
+ # Run the Streamlit app
31
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]