Crcs1225 commited on
Commit
ccabb90
·
1 Parent(s): 39ebfce

optimize memory

Browse files
Files changed (2) hide show
  1. .dockerignore +6 -0
  2. Dockerfile +5 -5
.dockerignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.log
3
+ *.json
4
+ *.csv
5
+ .env
6
+ .git/
Dockerfile CHANGED
@@ -1,9 +1,8 @@
1
- # Use a slim Python base
2
  FROM python:3.11-slim
3
 
4
  WORKDIR /app
5
 
6
- # Install system deps (if you need Mongo client, etc.)
7
  RUN apt-get update && apt-get install -y build-essential
8
 
9
  # Set Hugging Face cache to writable path
@@ -12,15 +11,16 @@ ENV HF_HOME=/app/.cache
12
  # Create the cache directory explicitly
13
  RUN mkdir -p /app/.cache
14
 
15
- # Copy requirements and install
16
  COPY requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
 
 
 
19
  # Copy app code
20
  COPY . .
21
 
22
- # Expose port
23
  EXPOSE 7860
24
 
25
- # Run FastAPI with uvicorn
26
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
5
+ # Install system deps
6
  RUN apt-get update && apt-get install -y build-essential
7
 
8
  # Set Hugging Face cache to writable path
 
11
  # Create the cache directory explicitly
12
  RUN mkdir -p /app/.cache
13
 
14
+ # Install Python dependencies
15
  COPY requirements.txt .
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ # Pre-download the embedding model
19
+ RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
20
+
21
  # Copy app code
22
  COPY . .
23
 
 
24
  EXPOSE 7860
25
 
 
26
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]