ShutterStack commited on
Commit
b4cdbd5
·
verified ·
1 Parent(s): dcb3295

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -12
Dockerfile CHANGED
@@ -1,26 +1,35 @@
1
- # Use a Python base image suitable for Streamlit and Flask
2
  FROM python:3.10
3
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Copy the requirements file and install Python dependencies
8
- # This leverages Docker's build cache.
9
  COPY requirements.txt .
 
 
 
 
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
12
- # Copy all your application code into the container
 
 
 
 
13
  # This includes main.py, streamlit_app.py, routers/, utils/, data/, etc.
14
  COPY . .
15
 
16
- # Ensure the 'data' directory exists inside the container, as your Flask app expects it.
17
- RUN mkdir -p data
 
 
 
18
 
19
- # Expose the port Streamlit will listen on.
20
- # Hugging Face Spaces automatically exposes port 7860 for Streamlit apps.
21
  EXPOSE 7860
22
 
23
- # Command to run on container startup
24
- # This command starts the Flask backend in the background and then runs the Streamlit frontend.
25
- # Streamlit will then interact with your Flask application on localhost:5000.
26
- CMD ["sh", "-c", "python main.py & streamlit run streamlit_app.py --server.port=7860 --server.address=0.0.0.0"]
 
1
+ # Use a slim Python base image for efficiency
2
  FROM python:3.10
3
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
+ # Copy the requirements.txt file first to leverage Docker's build cache.
8
+ # If requirements.txt doesn't change, this step won't re-run.
9
  COPY requirements.txt .
10
+
11
+ # Install Python dependencies
12
+ # --no-cache-dir: Reduces image size by not storing build cache
13
+ # -r requirements.txt: Installs all packages listed in requirements.txt
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Install Nginx
17
+ RUN apt-get update && apt-get install -y nginx && \
18
+ rm -rf /var/lib/apt/lists/*
19
+
20
+ # Copy the entire project directory into the container's /app directory.
21
  # This includes main.py, streamlit_app.py, routers/, utils/, data/, etc.
22
  COPY . .
23
 
24
+ # Replace the default Nginx configuration with your custom one
25
+ COPY nginx.conf /etc/nginx/nginx.conf
26
+
27
+ # Grant execution permissions to the start.sh script
28
+ RUN chmod +x start.sh
29
 
30
+ # Expose the port Nginx is configured to listen on (7860 for Hugging Face Spaces)
 
31
  EXPOSE 7860
32
 
33
+ # Define the command to run when the container starts.
34
+ # This executes your start.sh script which then launches Flask, Streamlit, and Nginx.
35
+ CMD ["./start.sh"]