Upload folder using huggingface_hub
Browse files- Dockerfile +9 -8
Dockerfile
CHANGED
|
@@ -2,12 +2,15 @@ FROM python:3.12-slim
|
|
| 2 |
|
| 3 |
# Non-root user (HF Spaces convention; writable HOME for the HF cache the model
|
| 4 |
# is pulled into at boot).
|
|
|
|
|
|
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
USER user
|
| 7 |
ENV HOME=/home/user \
|
| 8 |
PATH=/home/user/.local/bin:$PATH \
|
| 9 |
HF_HOME=/home/user/.cache/huggingface \
|
| 10 |
-
PYTHONUNBUFFERED=1
|
|
|
|
| 11 |
|
| 12 |
WORKDIR /home/user/app
|
| 13 |
|
|
@@ -20,16 +23,14 @@ USER user
|
|
| 20 |
# model; the mock path works on flask alone.
|
| 21 |
RUN pip install --no-cache-dir --user torch --index-url https://download.pytorch.org/whl/cpu
|
| 22 |
RUN pip install --no-cache-dir --user flask gunicorn protobuf
|
| 23 |
-
# GLiNER2 from
|
| 24 |
-
RUN pip install --no-cache-dir --user "gliner2[local] @ git+https://github.com/fastino-ai/GLiNER2.git@
|
| 25 |
|
| 26 |
COPY --chown=user . .
|
| 27 |
|
| 28 |
-
# Pre-download model at build time to speed up cold starts
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
ENV HF_TOKEN=${HF_TOKEN}
|
| 32 |
-
RUN python -c "import os; os.environ.setdefault('HF_TOKEN', os.environ.get('HF_TOKEN', '')); from huggingface_hub import snapshot_download; snapshot_download('fastino/gliner2.5-multi-v1')" || echo "model pre-download skipped (no HF_TOKEN)"
|
| 33 |
|
| 34 |
EXPOSE 7860
|
| 35 |
|
|
|
|
| 2 |
|
| 3 |
# Non-root user (HF Spaces convention; writable HOME for the HF cache the model
|
| 4 |
# is pulled into at boot).
|
| 5 |
+
# GLINER_MOCK=0: the deployed Space runs live inference (the local dev kit
|
| 6 |
+
# defaults to mock; the env var flips only this image).
|
| 7 |
RUN useradd -m -u 1000 user
|
| 8 |
USER user
|
| 9 |
ENV HOME=/home/user \
|
| 10 |
PATH=/home/user/.local/bin:$PATH \
|
| 11 |
HF_HOME=/home/user/.cache/huggingface \
|
| 12 |
+
PYTHONUNBUFFERED=1 \
|
| 13 |
+
GLINER_MOCK=0
|
| 14 |
|
| 15 |
WORKDIR /home/user/app
|
| 16 |
|
|
|
|
| 23 |
# model; the mock path works on flask alone.
|
| 24 |
RUN pip install --no-cache-dir --user torch --index-url https://download.pytorch.org/whl/cpu
|
| 25 |
RUN pip install --no-cache-dir --user flask gunicorn protobuf
|
| 26 |
+
# GLiNER2 from main branch (required for boundary architecture support)
|
| 27 |
+
RUN pip install --no-cache-dir --user "gliner2[local] @ git+https://github.com/fastino-ai/GLiNER2.git@main"
|
| 28 |
|
| 29 |
COPY --chown=user . .
|
| 30 |
|
| 31 |
+
# Pre-download model at build time to speed up cold starts. The model repo is
|
| 32 |
+
# public on the HF hub, so no token is needed.
|
| 33 |
+
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('fastino/gliner2.5-multi-v1')" || echo "model pre-download skipped"
|
|
|
|
|
|
|
| 34 |
|
| 35 |
EXPOSE 7860
|
| 36 |
|