Spaces:
Running
Running
File size: 2,492 Bytes
b35cede 96baece b35cede 96baece b35cede | 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 51 52 53 54 55 56 57 58 | FROM ghcr.io/tashfeenahmed/freellmapi:latest
# HF Spaces runs containers as UID 1000 and expects the app on port 7860.
# The base image already runs as `node` (uid 1000) via its entrypoint,
# so this stays compatible. We only remap port + DB path and fix perms.
USER root
# ---------------------------------------------------------------------------
# Dev Mode support — REQUIRED while Space Settings -> Dev Mode is ON.
#
# When Dev Mode is enabled, Hugging Face appends extra build stages to this
# file and runs these steps INSIDE THIS IMAGE (stage-2 = the image below):
# RUN git config --global user.name "<owner>"
# RUN git config --global user.email "<owner>@users.noreply.huggingface.co"
# RUN mkdir -p /home/user && ( [ -e /home/user/app ] || ln -s /app/ /home/user/app )
# RUN ln -s /dev-mode/init-process /tmp/init-process
# LINK COPY --link --from=vscode /opt/openvscode-server /opt/openvscode-server
#
# The upstream runtime stage is node:20-bookworm-slim, which ships WITHOUT git.
# The injected `git config` step therefore died with:
# /bin/sh: 1: git: not found -> exit code 127
# which failed the whole Space build (BUILD_ERROR / "Job failed with exit code: 1").
#
# Installing git here fixes Dev Mode. wget is what the injected OpenVSCode
# Server stage uses; openssh-client/ca-certificates make the web IDE and SSH
# usable. Cached layer, harmless when Dev Mode is OFF.
# ---------------------------------------------------------------------------
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
ca-certificates \
openssh-client \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& git --version
RUN mkdir -p /data && chmod 777 /data \
&& mkdir -p /app/server/data && chown -R node:node /app/server/data || true
# Dev Mode opens a terminal with a non-root HOME; the injected build step also
# symlinks the app there (`ln -s /app /home/user/app`). Pre-create it writable.
RUN mkdir -p /home/user && chmod 777 /home/user
ENV NODE_ENV=production \
PORT=7860 \
HOST=:: \
FREELLMAPI_INSTALL_METHOD=docker \
FREEAPI_DB_PATH=/data/freellmapi.db
EXPOSE 7860
# Keep upstream entrypoint (fixes perms, then drops to `node`).
# Runs as root when possible so the entrypoint can chown /data;
# HF Spaces executes containers as UID 1000 — the entrypoint detects
# non-root and just execs the server directly (works since /data is 777).
USER root
CMD ["node", "server/dist/index.js"]
|