alidenewade commited on
Commit
c2527b4
·
verified ·
1 Parent(s): b7ab90f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -19
Dockerfile CHANGED
@@ -1,32 +1,40 @@
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
- # Install system dependencies needed by RDKit and other libraries *before* anything else.
8
- # This ensures required libraries like libXrender are available.
9
  RUN apt-get update && apt-get install -y \
10
- build-essential \
11
- libxrender1 \
12
- libfontconfig1 \
13
- libxext6 \
 
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Copy the requirements file into the container
17
- COPY requirements.txt ./requirements.txt
18
 
19
- # Install the Python dependencies
20
- RUN pip install --no-cache-dir --upgrade pip && \
21
- pip install --no-cache-dir -r requirements.txt
22
 
23
- # Copy the rest of your application's code into the container
24
  COPY . .
25
 
26
- # Expose the port that Streamlit will run on (Hugging Face default is 7860)
 
 
 
 
27
  EXPOSE 7860
28
 
29
- # Command to run the Streamlit app
30
- # - Add --server.gatherUsageStats=false to prevent the permission error.
31
- # - The --server.headless=true flag is recommended for containerized environments.
32
- CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.headless=true", "--server.gatherUsageStats=false"]
 
 
 
 
 
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 required for RDKit and other packages
 
8
  RUN apt-get update && apt-get install -y \
9
+ gcc \
10
+ g++ \
11
+ libssl-dev \
12
+ libffi-dev \
13
+ libxml2-dev \
14
+ libxslt-dev \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Copy requirements first for better Docker layer caching
18
+ COPY requirements.txt .
19
 
20
+ # Install Python dependencies
21
+ RUN pip install --no-cache-dir -r requirements.txt
 
22
 
23
+ # Copy the application code
24
  COPY . .
25
 
26
+ # Create a non-root user for security
27
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
28
+ USER appuser
29
+
30
+ # Expose the port that Streamlit uses
31
  EXPOSE 7860
32
 
33
+ # Set environment variables for Streamlit
34
+ ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
35
+ ENV STREAMLIT_SERVER_PORT=7860
36
+ ENV STREAMLIT_SERVER_HEADLESS=true
37
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
38
+
39
+ # Command to run the application
40
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]