Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +21 -12
Dockerfile
CHANGED
|
@@ -1,26 +1,35 @@
|
|
| 1 |
-
# Use a Python base image
|
| 2 |
FROM python:3.10
|
| 3 |
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy the requirements file
|
| 8 |
-
#
|
| 9 |
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# This includes main.py, streamlit_app.py, routers/, utils/, data/, etc.
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
# Expose the port
|
| 20 |
-
# Hugging Face Spaces automatically exposes port 7860 for Streamlit apps.
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
# This
|
| 25 |
-
|
| 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"]
|
|
|