Spaces:
Paused
Paused
File size: 1,998 Bytes
8ac5a25 095871d 8ac5a25 dbe0ec4 8ac5a25 fd5d7f3 8ac5a25 dbe0ec4 8ac5a25 dbe0ec4 8ac5a25 dbe0ec4 8ac5a25 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # DesirePath on a HuggingFace Docker Space.
#
# The static Space served files and made every visitor download a 900 MB model
# into their browser before the router would answer anything. This one runs the
# model on the Space instead, so the first query is fast and nothing is
# downloaded.
#
# The trade is real and is stated in the interface: with server inference the
# typed sentence reaches this container. The in-browser path is still here and
# is still private; ?llm=webgpu selects it.
FROM ollama/ollama:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg procps \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Granite 4 micro, baked into the image rather than pulled on boot. A Space
# that downloads 2.1 GB at startup looks broken for the first few minutes and
# does it again on every restart.
ENV OLLAMA_MODELS=/opt/ollama/models
COPY pull-model.sh /tmp/pull-model.sh
RUN chmod +x /tmp/pull-model.sh && /tmp/pull-model.sh && rm /tmp/pull-model.sh
# Spaces run the container as uid 1000, and everything below refers to that
# uid numerically rather than by name. The ollama base image already has a user
# at 1000 under a different name, so `useradd -u 1000 user` fails, `|| true`
# swallows it, and every later `chown user:user` dies with "invalid user".
ENV HOME=/home/user \
OLLAMA_HOST=127.0.0.1:11434 \
OLLAMA_ORIGINS=http://127.0.0.1:*,http://localhost:* \
PORT=7860
WORKDIR /app
COPY --chown=1000:1000 public/ /app/public/
COPY --chown=1000:1000 server.mjs /app/server.mjs
COPY --chown=1000:1000 start.sh /app/start.sh
RUN chmod +x /app/start.sh \
&& mkdir -p /home/user/.ollama \
&& chown -R 1000:1000 /opt/ollama /app /home/user
USER 1000
EXPOSE 7860
# The base image sets an entrypoint of /bin/ollama; we need a shell instead.
ENTRYPOINT []
CMD ["/app/start.sh"]
|