Percy3822 commited on
Commit
518554b
·
verified ·
1 Parent(s): 9acdd9a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -5
Dockerfile CHANGED
@@ -1,14 +1,21 @@
1
  FROM python:3.10-slim
2
 
3
- # Basics
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  curl ca-certificates libsndfile1 \
6
  && rm -rf /var/lib/apt/lists/*
7
 
8
  WORKDIR /code
9
 
10
- # Install CPU-only torch FIRST from the CPU index to avoid CUDA deps
11
- # Pin a stable CPU build that plays nicely with Transformers 4.46.x
 
 
 
 
 
 
 
12
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
13
  torch==2.3.1
14
 
@@ -19,8 +26,8 @@ RUN pip install --no-cache-dir -r requirements.txt
19
  # App
20
  COPY app.py .
21
 
22
- # Space variables (optional but nice for absolute URLs)
 
23
  ENV SPACE_HOST=${SPACE_ID}.hf.space
24
 
25
- # Run
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.10-slim
2
 
3
+ # System deps
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  curl ca-certificates libsndfile1 \
6
  && rm -rf /var/lib/apt/lists/*
7
 
8
  WORKDIR /code
9
 
10
+ # Make writable caches (Spaces persists /data)
11
+ ENV TRANSFORMERS_CACHE=/data/transformers \
12
+ HF_HOME=/data/huggingface \
13
+ HUGGINGFACE_HUB_CACHE=/data/hfhub \
14
+ PYTHONUNBUFFERED=1
15
+
16
+ RUN mkdir -p /data/transformers /data/huggingface /data/hfhub
17
+
18
+ # Install CPU-only torch FIRST to avoid pulling CUDA blobs
19
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
20
  torch==2.3.1
21
 
 
26
  # App
27
  COPY app.py .
28
 
29
+ # If you want fully-qualified URLs back, expose your space host like this:
30
+ # (HF sets SPACE_ID automatically; this builds a FQDN inside the app)
31
  ENV SPACE_HOST=${SPACE_ID}.hf.space
32
 
 
33
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]