42Cummer commited on
Commit
26c92d2
·
verified ·
1 Parent(s): 32d42e5

Update dockferfile

Browse files
Files changed (1) hide show
  1. dockferfile +29 -14
dockferfile CHANGED
@@ -1,21 +1,36 @@
 
1
  FROM python:3.11-slim
2
 
3
- # non-root user (HF recommendation)
4
- RUN useradd -m -u 1000 user
5
- USER user
6
- ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
7
- WORKDIR $HOME/app
 
8
 
9
- # persistent storage on Spaces -> /data
10
- RUN mkdir -p /data /data/models
 
 
 
 
 
11
 
12
- # copy code
13
- COPY --chown=user . $HOME/app
14
 
15
- # install deps
16
- RUN pip install --no-cache-dir -U pip \
17
- && pip install --no-cache-dir -r requirements.txt
18
 
19
- # expose port and run
 
 
 
 
 
 
 
20
  EXPOSE 7860
21
- CMD ["gunicorn", "-k", "gevent", "-w", "1", "-b", "0.0.0.0:7860", "app:app"]
 
 
 
1
+ # Use lightweight Python base
2
  FROM python:3.11-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1 \
7
+ HF_HOME=/tmp/huggingface \
8
+ TRANSFORMERS_CACHE=/tmp/huggingface \
9
+ HF_HUB_CACHE=/tmp/huggingface
10
 
11
+ # Install system deps
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ build-essential \
14
+ git \
15
+ curl \
16
+ cmake \
17
+ && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Create working directory
20
+ WORKDIR /app
21
 
22
+ # Copy requirements (create a requirements.txt alongside app.py)
23
+ COPY requirements.txt .
 
24
 
25
+ # Install Python deps
26
+ RUN pip install --upgrade pip \
27
+ && pip install -r requirements.txt
28
+
29
+ # Copy the source code
30
+ COPY . .
31
+
32
+ # Expose HF Spaces port
33
  EXPOSE 7860
34
+
35
+ # Run FastAPI server
36
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]