File size: 1,456 Bytes
a18f083
37023b5
 
 
 
 
a18f083
 
 
191ca7d
a18f083
191ca7d
 
a18f083
 
37023b5
a18f083
37023b5
 
a18f083
 
 
191ca7d
 
 
a18f083
 
191ca7d
a18f083
 
37023b5
 
 
a18f083
 
37023b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Use a Python base image suitable for slim deployments
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# --- Handle caching for Sentence-Transformers and Hugging Face models ---
# Create a writable directory for the Hugging Face cache
# Ensure permissions allow the application user (root by default in this base image) to write
RUN mkdir -p /app/.cache && chmod 777 /app/.cache
# Set the environment variable to tell Hugging Face libraries where to cache models
ENV HUGGINGFACE_HUB_CACHE="/app/.cache"

# --- Install Dependencies ---
# Copy the requirements file first to leverage Docker cache layers
COPY requirements.txt .
# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# --- Copy Application Code ---
# Copy the rest of the application code into the working directory
# Explicitly copy directories to ensure they land in the correct place relative to /app
COPY app.py .
COPY templates /app/templates
COPY static /app/static
# Copy the README file - Corrected: comment moved to its own line
COPY README.md .

# --- Configure Application Startup ---
# Expose the port the Flask app will run on. Hugging Face Spaces Docker requires 7860.
EXPOSE 7860

# Define the command to run your application using Waitress
# Waitress serves the 'app' object from your 'app.py' file
# It listens on all interfaces (0.0.0.0) on port 7860
CMD ["waitress-serve", "--listen=0.0.0.0:7860", "app:app"]