swaroop77 commited on
Commit
a18f083
·
verified ·
1 Parent(s): b405f41

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # Create a writable directory for Hugging Face cache
 
 
8
  RUN mkdir -p /app/.cache && chmod 777 /app/.cache
9
- # Set the cache environment variable
10
  ENV HUGGINGFACE_HUB_CACHE="/app/.cache"
11
 
12
- # Copy the requirements file and install dependencies
 
13
  COPY requirements.txt .
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Copy the rest of the application code
17
- # Explicitly copy directories to ensure they land in /app/templates and /app/static
 
18
  COPY app.py .
19
  COPY templates /app/templates
20
  COPY static /app/static
21
- COPY README.md . # Ensure README is copied too
 
22
 
23
-
24
- # Expose the port the app runs on (Hugging Face requires 7860 for web apps)
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"]