Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +14 -6
Dockerfile
CHANGED
|
@@ -1,17 +1,25 @@
|
|
| 1 |
-
ENV HF_HOME=/app/cache
|
| 2 |
-
|
| 3 |
FROM python:3.10
|
| 4 |
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
COPY requirements.txt .
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
|
| 12 |
-
AutoTokenizer.from_pretrained('
|
| 13 |
-
AutoModelForCausalLM.from_pretrained('
|
| 14 |
|
|
|
|
| 15 |
COPY app.py .
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# System deps
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
git \
|
| 8 |
+
curl \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
# Install Python deps
|
| 12 |
COPY requirements.txt .
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
| 15 |
+
# Pre-download model (IMPORTANT: avoids runtime network issues)
|
| 16 |
RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
|
| 17 |
+
AutoTokenizer.from_pretrained('distilgpt2'); \
|
| 18 |
+
AutoModelForCausalLM.from_pretrained('distilgpt2')"
|
| 19 |
|
| 20 |
+
# Copy app
|
| 21 |
COPY app.py .
|
| 22 |
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
|
| 25 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|