alidenewade commited on
Commit
cb30ac0
·
verified ·
1 Parent(s): 98164bf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -12
Dockerfile CHANGED
@@ -1,22 +1,39 @@
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
- # Copy the requirements file into the container
 
 
 
 
 
 
 
 
 
 
 
 
8
  COPY requirements.txt .
9
 
10
- # Install the Python dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt && \
12
- find . -type d -name "__pycache__" -exec rm -rf {} +;
13
 
14
- # Copy the Streamlit application file into the container
15
- COPY app.py .
16
 
17
- # Expose the port Streamlit runs on (default for Hugging Face Spaces is 7860)
 
 
 
 
18
  EXPOSE 7860
19
 
20
- # Define the command to run the Streamlit application
21
- # Simplified CMD command for better compatibility with Hugging Face Spaces
22
- CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.host", "0.0.0.0"]
 
 
 
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
+ # Set environment variables
8
+ ENV PYTHONUNBUFFERED=1
9
+ ENV PYTHONDONTWRITEBYTECODE=1
10
+
11
+ # Install system dependencies
12
+ RUN apt-get update && apt-get install -y \
13
+ build-essential \
14
+ curl \
15
+ software-properties-common \
16
+ git \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # Copy requirements first for better Docker layer caching
20
  COPY requirements.txt .
21
 
22
+ # Install Python dependencies
23
+ RUN pip install --no-cache-dir -r requirements.txt
 
24
 
25
+ # Copy the application code
26
+ COPY . .
27
 
28
+ # Create a non-root user for security
29
+ RUN useradd -m -u 1000 user
30
+ USER user
31
+
32
+ # Expose the port that Streamlit runs on
33
  EXPOSE 7860
34
 
35
+ # Health check
36
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
37
+
38
+ # Command to run the application
39
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]