Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -25
Dockerfile
CHANGED
|
@@ -1,38 +1,26 @@
|
|
| 1 |
-
# Use a Python base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
#
|
| 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
|
| 18 |
-
|
| 19 |
-
COPY
|
| 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 |
-
#
|
| 32 |
-
RUN
|
| 33 |
|
| 34 |
-
# Expose the port
|
|
|
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
# Command to run on container startup
|
| 38 |
-
|
|
|
|
|
|
|
|
|
| 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"]
|