alidenewade commited on
Commit
8ceb4fa
·
verified ·
1 Parent(s): 7962386

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -29
Dockerfile CHANGED
@@ -1,39 +1,23 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Install system dependencies that might be needed for scientific packages
8
- RUN apt-get update && apt-get install -y \
9
- gcc \
10
- g++ \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Copy the requirements file into the container at /app
14
  COPY requirements.txt .
15
 
16
- # Install any needed packages specified in requirements.txt
17
- # Using --no-cache-dir to reduce image size
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
- # Copy the rest of the application's code into the container at /app
21
- COPY . .
22
-
23
- # Create a non-root user for security
24
- RUN useradd --create-home --shell /bin/bash streamlit
25
- RUN chown -R streamlit:streamlit /app
26
- USER streamlit
27
 
28
- # Make port 8501 available to the world outside this container
29
- EXPOSE 8501
30
 
31
- # Define environment variables
32
- ENV STREAMLIT_SERVER_PORT=8501
33
- ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
34
- ENV STREAMLIT_SERVER_HEADLESS=true
35
- ENV STREAMLIT_SERVER_ENABLE_CORS=false
36
- ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
37
 
38
- # Run app.py when the container launches
39
- CMD ["streamlit", "run", "app.py"]
 
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
+ # Using --no-cache-dir to save space
12
+ # Using find . -type d -name "__pycache__" -exec rm -rf {} +; to clean up __pycache__
13
+ RUN pip install --no-cache-dir -r requirements.txt && \
14
+ find . -type d -name "__pycache__" -exec rm -rf {} +;
 
 
 
 
 
 
15
 
16
+ # Copy the Streamlit application file into the container
17
+ COPY app.py .
18
 
19
+ # Expose the port Streamlit runs on (default for Hugging Face Spaces is 7860)
20
+ EXPOSE 7860
 
 
 
 
21
 
22
+ # Define the command to run the Streamlit application
23
+ CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]