366degrees commited on
Commit
974c440
·
verified ·
1 Parent(s): 297ce93

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -36
Dockerfile CHANGED
@@ -1,47 +1,28 @@
1
- # ==========================================================
2
- # SNP Universal Embedding - Custom Inference Container
3
- # Replicates the exact Hugging Face Spaces runtime
4
- # ==========================================================
5
-
6
  FROM python:3.10-slim
7
 
8
- # ----------------------------------------------------------
9
- # 1. System setup
10
- # ----------------------------------------------------------
11
- ENV PYTHONUNBUFFERED=1
12
- ENV PORT=7860
13
  WORKDIR /app
14
 
15
- # Install essential system packages
16
- RUN apt-get update && apt-get install -y \
17
- git wget curl build-essential && \
18
- rm -rf /var/lib/apt/lists/*
19
-
20
- # ----------------------------------------------------------
21
- # 2. Copy model and code
22
- # ----------------------------------------------------------
23
- COPY . /app
24
 
25
- # ----------------------------------------------------------
26
- # 3. Install Python dependencies
27
- # ----------------------------------------------------------
28
- RUN pip install --no-cache-dir --upgrade pip
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
- # ----------------------------------------------------------
32
- # 4. Environment variables (optional)
33
- # ----------------------------------------------------------
34
- # Set these if needed by your inference API
35
- # ENV MODEL_PATH="./"
36
- # ENV HF_HOME="/root/.cache/huggingface"
37
 
38
- # ----------------------------------------------------------
39
- # 5. Expose Flask port
40
- # ----------------------------------------------------------
41
  EXPOSE 7860
42
 
43
- # ----------------------------------------------------------
44
- # 6. Launch your API server (same as Spaces)
45
- # ----------------------------------------------------------
46
- CMD ["python", "api_inference.py"]
47
 
 
 
 
1
+ # Use lightweight Python base
 
 
 
 
2
  FROM python:3.10-slim
3
 
4
+ # Set working directory
 
 
 
 
5
  WORKDIR /app
6
 
7
+ # Copy files
8
+ COPY . .
 
 
 
 
 
 
 
9
 
10
+ # Install dependencies
 
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Create cache directory and make it writable for non-root
14
+ RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
15
+
16
+ # Set environment variables for Hugging Face cache
17
+ ENV HF_HOME=/app/hf_cache
18
+ ENV TRANSFORMERS_CACHE=/app/hf_cache
19
 
20
+ # Expose Space port
 
 
21
  EXPOSE 7860
22
 
23
+ # Switch to non-root user
24
+ RUN useradd -m appuser
25
+ USER appuser
 
26
 
27
+ # Run Flask directly (no Gunicorn)
28
+ CMD ["python", "api_inference.py"]