kamp0010 commited on
Commit
395d302
·
verified ·
1 Parent(s): 872bcb0

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -0
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install build deps
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ build-essential git curl \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ COPY requirements.txt .
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ COPY main.py .
14
+
15
+ # HuggingFace Spaces runs as non-root user 1000
16
+ RUN useradd -m -u 1000 user
17
+ # Pre-download models into the image cache so cold starts are fast
18
+ # (comment out these two lines if you want a smaller image and can tolerate the first-run download)
19
+ RUN python -c "\
20
+ import builtins; builtins.input = lambda p='': 'y'; \
21
+ import os; os.environ['HF_HUB_VERBOSITY']='error'; \
22
+ from transformers import AutoModel, AutoTokenizer; \
23
+ AutoModel.from_pretrained('perplexity-ai/pplx-embed-context-v1-0.6B', trust_remote_code=True); \
24
+ AutoModel.from_pretrained('perplexity-ai/pplx-embed-v1-0.6B', trust_remote_code=True); \
25
+ AutoTokenizer.from_pretrained('perplexity-ai/pplx-embed-v1-0.6B', trust_remote_code=True); \
26
+ print('Models cached.')"
27
+
28
+ USER user
29
+ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
30
+
31
+ EXPOSE 7860
32
+
33
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]