ShutterStack commited on
Commit
b8611e0
·
verified ·
1 Parent(s): 153e1be

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -25
Dockerfile CHANGED
@@ -1,38 +1,26 @@
1
- # Use a Python base image with a good balance of size and features
2
  FROM python:3.9-slim
3
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Install system dependencies (Nginx, etc.)
8
- # Run apt-get update first, then install packages, then clean up apt cache
9
- RUN apt-get update && \
10
- apt-get install -y --no-install-recommends nginx && \
11
- rm -rf /var/lib/apt/lists/*
12
-
13
- # Copy the combined requirements file and install Python dependencies
14
  COPY requirements.txt .
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # Copy your Flask backend and Streamlit frontend code
18
- COPY flask_backend/ ./flask_backend/
19
- COPY streamlit_frontend/ ./streamlit_frontend/
20
- # If you have a sample dataset you want to include
21
- COPY data/ ./data/
22
-
23
- # Copy Nginx configuration and startup script
24
- COPY nginx.conf /etc/nginx/sites-available/default
25
- COPY start.sh .
26
-
27
- # Ensure Nginx uses our config
28
- RUN ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default && \
29
- rm -rf /etc/nginx/sites-enabled/default.bak
30
 
31
- # Make the startup script executable
32
- RUN chmod +x start.sh
33
 
34
- # Expose the port Nginx will listen on (Hugging Face Spaces will expose this to the internet)
 
35
  EXPOSE 7860
36
 
37
  # Command to run on container startup
38
- CMD ["./start.sh"]
 
 
 
1
+ # Use a Python base image suitable for Streamlit and Flask
2
  FROM python:3.9-slim
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"]