Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +9 -6
Dockerfile
CHANGED
|
@@ -2,16 +2,18 @@ FROM python:3.11-slim
|
|
| 2 |
|
| 3 |
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
PIP_NO_CACHE_DIR=1 \
|
| 5 |
-
HF_HOME=/
|
| 6 |
-
TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
WORKDIR /app
|
| 12 |
COPY requirements.txt /app/requirements.txt
|
| 13 |
|
| 14 |
-
# Install CPU torch first
|
| 15 |
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.3.1+cpu \
|
| 16 |
&& pip install --no-cache-dir -r /app/requirements.txt
|
| 17 |
|
|
@@ -19,6 +21,7 @@ COPY main.py /app/main.py
|
|
| 19 |
|
| 20 |
EXPOSE 7860
|
| 21 |
ENV MODEL_ID="ethnmcl/checkin-gpt2"
|
| 22 |
-
# If
|
| 23 |
|
| 24 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
| 2 |
|
| 3 |
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
PIP_NO_CACHE_DIR=1 \
|
| 5 |
+
HF_HOME=/data/huggingface
|
|
|
|
| 6 |
|
| 7 |
+
# Create a writable, persistent cache directory in Spaces
|
| 8 |
+
RUN mkdir -p /data/huggingface && chmod -R 777 /data
|
| 9 |
+
|
| 10 |
+
# (Optional) system tools
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
WORKDIR /app
|
| 14 |
COPY requirements.txt /app/requirements.txt
|
| 15 |
|
| 16 |
+
# Install CPU torch first (smaller, no CUDA), then the rest
|
| 17 |
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.3.1+cpu \
|
| 18 |
&& pip install --no-cache-dir -r /app/requirements.txt
|
| 19 |
|
|
|
|
| 21 |
|
| 22 |
EXPOSE 7860
|
| 23 |
ENV MODEL_ID="ethnmcl/checkin-gpt2"
|
| 24 |
+
# If the model repo is private, set a Space Secret named HF_TOKEN (Settings → Secrets)
|
| 25 |
|
| 26 |
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 27 |
+
|