mic3333 commited on
Commit
126eb46
·
verified ·
1 Parent(s): 68b0ce2

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /code
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ gcc \
8
+ g++ \
9
+ git \
10
+ wget \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Set environment variables
14
+ ENV TRANSFORMERS_CACHE=/code/cache
15
+ ENV HF_HOME=/code/cache
16
+ ENV TOKENIZERS_PARALLELISM=false
17
+
18
+ # Copy requirements first for better caching
19
+ COPY requirements.txt /code/requirements.txt
20
+
21
+ # Install Python dependencies
22
+ RUN pip install --no-cache-dir --upgrade pip
23
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
24
+
25
+ # Download models at build time to avoid runtime delays
26
+ RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
27
+
28
+ # Copy the application code
29
+ COPY . /code
30
+
31
+ # Create cache directory
32
+ RUN mkdir -p /code/cache
33
+
34
+ # Expose port 7860 for Hugging Face Spaces
35
+ EXPOSE 7860
36
+
37
+ # Run the application
38
+ CMD ["python", "app.py"]