Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- Dockerfile +24 -0
- app.zip +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
WORKDIR /app
|
| 3 |
+
|
| 4 |
+
# The user will only upload app.zip and this Dockerfile
|
| 5 |
+
COPY app.zip .
|
| 6 |
+
|
| 7 |
+
# Install unzip, extract the application, and clean up the zip file
|
| 8 |
+
# (also install build-essential for tokenizer dependencies)
|
| 9 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
+
unzip \
|
| 11 |
+
build-essential \
|
| 12 |
+
&& unzip -o app.zip && rm app.zip \
|
| 13 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
+
|
| 15 |
+
# Install dependencies from the extracted requirements.txt
|
| 16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
+
|
| 18 |
+
# Pre-download the tokenizer during the Docker build (setting cache dir to /app/cache to ensure it persists across users)
|
| 19 |
+
ENV HF_HOME=/app/cache
|
| 20 |
+
RUN python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('unsloth/Llama-3.2-3B-Instruct')"
|
| 21 |
+
|
| 22 |
+
EXPOSE 8000
|
| 23 |
+
# We use --preload so the master process downloads the tokenizer ONCE before forking the workers
|
| 24 |
+
CMD ["gunicorn", "--preload", "--timeout", "120", "-w", "4", "-b", "0.0.0.0:8000", "app:app"]
|
app.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d754d77be3321297044f72c3b741d57033e9690e28bce9b7c1f32dccc75cfea3
|
| 3 |
+
size 1110651
|