alidenewade commited on
Commit
f1085d3
·
verified ·
1 Parent(s): 06a466c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -20
Dockerfile CHANGED
@@ -1,35 +1,37 @@
1
- # Use the official Hugging Face Spaces base image
2
- FROM python:3.10-slim
3
 
4
- # Set working directory
5
- WORKDIR /home/user/app
6
 
7
- # Install system dependencies
 
8
  RUN apt-get update && apt-get install -y \
9
- curl \
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Copy requirements and install Python dependencies
 
13
  COPY requirements.txt .
14
- RUN pip install --no-cache-dir --upgrade pip && \
15
- pip install --no-cache-dir "numpy<2.0.0" && \
16
- pip install --no-cache-dir -r requirements.txt
17
 
18
- # Copy the application code
19
- COPY . .
20
 
21
- # Create user
22
- RUN useradd -m -u 1000 user
23
- USER user
24
 
25
- # Expose the port that Streamlit runs on
26
  EXPOSE 7860
27
 
28
- # Set environment variables for Streamlit
29
- ENV STREAMLIT_SERVER_PORT=7860
30
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
 
31
  ENV STREAMLIT_SERVER_HEADLESS=true
32
  ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
33
 
34
- # Run the Streamlit app
35
- CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
 
1
+ # Use Python 3.9 slim image as base, which is a good choice for stability and size.
2
+ FROM python:3.9-slim
3
 
4
+ # Set the working directory inside the container
5
+ WORKDIR /app
6
 
7
+ # Install system dependencies required for RDKit and other graphical libraries.
8
+ # This is a crucial step for rdkit-pypi to work correctly in a Linux container.
9
  RUN apt-get update && apt-get install -y \
10
+ gcc \
11
+ g++ \
12
+ libxext6 \
13
+ libxrender1 \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Copy the requirements file first to leverage Docker's layer caching.
17
+ # The Docker build will only re-run the pip install step if this file changes.
18
  COPY requirements.txt .
 
 
 
19
 
20
+ # Install the Python dependencies specified in requirements.txt
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy the rest of your application code into the container
24
+ COPY . .
 
25
 
26
+ # Expose the port that Streamlit will run on. Hugging Face Spaces typically uses 7860.
27
  EXPOSE 7860
28
 
29
+ # Set environment variables for Streamlit to run in a headless environment.
 
30
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
31
+ ENV STREAMLIT_SERVER_PORT=7860
32
  ENV STREAMLIT_SERVER_HEADLESS=true
33
  ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
34
 
35
+ # The command to run your Streamlit application when the container starts.
36
+ # It points to the app.py file and sets the server address and port.
37
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]