Update Dockerfile
Browse files- Dockerfile +17 -9
Dockerfile
CHANGED
|
@@ -1,28 +1,36 @@
|
|
| 1 |
-
# Use a Python base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
| 8 |
RUN mkdir -p /app/.cache && chmod 777 /app/.cache
|
| 9 |
-
# Set the
|
| 10 |
ENV HUGGINGFACE_HUB_CACHE="/app/.cache"
|
| 11 |
|
| 12 |
-
#
|
|
|
|
| 13 |
COPY requirements.txt .
|
|
|
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
# Copy
|
| 17 |
-
#
|
|
|
|
| 18 |
COPY app.py .
|
| 19 |
COPY templates /app/templates
|
| 20 |
COPY static /app/static
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
# Expose the port the app
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
# Define the command to run your application using Waitress
|
|
|
|
|
|
|
| 28 |
CMD ["waitress-serve", "--listen=0.0.0.0:7860", "app:app"]
|
|
|
|
| 1 |
+
# Use a Python base image suitable for slim deployments
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# --- Handle caching for Sentence-Transformers and Hugging Face models ---
|
| 8 |
+
# Create a writable directory for the Hugging Face cache
|
| 9 |
+
# Ensure permissions allow the application user (root by default in this base image) to write
|
| 10 |
RUN mkdir -p /app/.cache && chmod 777 /app/.cache
|
| 11 |
+
# Set the environment variable to tell Hugging Face libraries where to cache models
|
| 12 |
ENV HUGGINGFACE_HUB_CACHE="/app/.cache"
|
| 13 |
|
| 14 |
+
# --- Install Dependencies ---
|
| 15 |
+
# Copy the requirements file first to leverage Docker cache layers
|
| 16 |
COPY requirements.txt .
|
| 17 |
+
# Install the Python dependencies
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
+
# --- Copy Application Code ---
|
| 21 |
+
# Copy the rest of the application code into the working directory
|
| 22 |
+
# Explicitly copy directories to ensure they land in the correct place relative to /app
|
| 23 |
COPY app.py .
|
| 24 |
COPY templates /app/templates
|
| 25 |
COPY static /app/static
|
| 26 |
+
# Copy the README file - Corrected: comment moved to its own line
|
| 27 |
+
COPY README.md .
|
| 28 |
|
| 29 |
+
# --- Configure Application Startup ---
|
| 30 |
+
# Expose the port the Flask app will run on. Hugging Face Spaces Docker requires 7860.
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
# Define the command to run your application using Waitress
|
| 34 |
+
# Waitress serves the 'app' object from your 'app.py' file
|
| 35 |
+
# It listens on all interfaces (0.0.0.0) on port 7860
|
| 36 |
CMD ["waitress-serve", "--listen=0.0.0.0:7860", "app:app"]
|