Download Dockerfile from Zero124/VR-MEDIA: direct link, hf CLI and curl.
- Browser
- Download file 4.52 kB
-
https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Zero124/VR-MEDIA/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/Dockerfile
4.52 kB
| # VR Media Server 2.0 β Hugging Face Docker Space | |
| # ----------------------------------------------- | |
| # Builds a self-contained Next.js + ffmpeg image that runs on HF free tier | |
| # (16GB RAM / 2 vCPU). App listens on port 7860 (HF Spaces default). | |
| # Persistent state lives in /data β mount as a HF Space persistent storage. | |
| # | |
| # NOTE: The node:20-slim base image already ships a `node` user with UID 1000. | |
| # HF Spaces requires the app to run as UID 1000, so we reuse that user instead | |
| # of creating a new one (which would fail with "UID 1000 is not unique"). | |
| # | |
| # SCHEMA STRATEGY: We create a seed SQLite database at BUILD time (with the | |
| # full Prisma schema already pushed), copy it into the runtime image, and at | |
| # runtime just `cp` it to /data/vrms.db if it doesn't exist. This avoids | |
| # needing the Prisma CLI (and its many transitive deps like `effect`) in the | |
| # runtime image β keeps the image small and the startup fast. | |
| # ---------- Stage 1: base with system deps ---------- | |
| FROM node:20-slim AS base | |
| # Install ffmpeg (provides both ffmpeg + ffprobe) and OpenSSL (Prisma needs it). | |
| # ca-certificates + curl for health checks and Offcloud HTTPS calls. | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ffmpeg \ | |
| openssl \ | |
| ca-certificates \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install bun (faster than npm for installing deps; matches dev environment). | |
| RUN npm install -g bun | |
| # ---------- Stage 2: install deps ---------- | |
| FROM base AS deps | |
| WORKDIR /app | |
| # Copy manifest first for layer caching. | |
| COPY package.json ./ | |
| COPY prisma ./prisma | |
| # Install dependencies (regenerates lockfile on first build). | |
| RUN bun install | |
| # ---------- Stage 3: build ---------- | |
| FROM deps AS builder | |
| WORKDIR /app | |
| # Copy source. | |
| COPY . . | |
| # Generate Prisma client (schema is already in deps stage). | |
| RUN bun run db:generate | |
| # Next.js standalone build β produces a self-contained server. | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| RUN bun run build | |
| # Create a seed SQLite database with the schema already pushed. | |
| # We use a throwaway path; the file is copied into the runtime stage. | |
| # This runs at BUILD time, so the full Prisma CLI + all its deps are available | |
| # here in the builder stage β they just don't ship to runtime. | |
| RUN DATABASE_URL=file:/tmp/seed.db bun run db:push --skip-generate --accept-data-loss && \ | |
| ls -la /tmp/seed.db | |
| # ---------- Stage 4: runtime ---------- | |
| FROM base AS runner | |
| WORKDIR /app | |
| # The node:20-slim base image already has a `node` user with UID 1000. | |
| # HF Spaces requires UID 1000, so we reuse it β no user creation needed. | |
| # We just ensure /data exists and is owned by node. | |
| RUN mkdir -p /data && chown -R node:node /data | |
| # Copy the standalone Next.js server + static assets. | |
| # --chown=node:node so the node user can read everything. | |
| COPY --from=builder --chown=node:node /app/.next/standalone ./ | |
| COPY --from=builder --chown=node:node /app/.next/static ./.next/static | |
| COPY --from=builder --chown=node:node /app/public ./public | |
| # Copy the Prisma schema (for reference) and the generated client (needed by the app at runtime). | |
| COPY --from=builder --chown=node:node /app/prisma ./prisma | |
| COPY --from=builder --chown=node:node /app/node_modules/.prisma ./node_modules/.prisma | |
| COPY --from=builder --chown=node:node /app/node_modules/@prisma ./node_modules/@prisma | |
| # Copy the seed database created at build time. The entrypoint will use this | |
| # to initialize /data/vrms.db on first run. | |
| COPY --from=builder --chown=node:node /tmp/seed.db /app/seed.db | |
| # Copy the entrypoint script and make it executable. Normalise line endings | |
| # first: an upload made on Windows can otherwise leave CRLF in the shebang, | |
| # which makes the kernel report "/app/docker-entrypoint.sh: not found". | |
| COPY --chown=node:node docker-entrypoint.sh /app/docker-entrypoint.sh | |
| COPY --chown=node:node scripts /app/scripts | |
| RUN sed -i 's/\r$//' /app/docker-entrypoint.sh && chmod +x /app/docker-entrypoint.sh | |
| # Environment. HF Spaces exposes 7860 by default β match it. | |
| ENV NODE_ENV=production | |
| ENV PORT=7860 | |
| ENV HOSTNAME=0.0.0.0 | |
| ENV DATABASE_URL=file:/data/vrms.db | |
| ENV NEXT_TELEMETRY_DISABLED=1 | |
| # HF persistent storage is mounted at /data. We expose it as a volume. | |
| VOLUME ["/data"] | |
| EXPOSE 7860 | |
| # Run as the existing node user (UID 1000) β required by HF Spaces. | |
| USER node | |
| # Run the entrypoint: initializes /data/vrms.db from seed if missing, then starts Next.js. | |
| # Invoke it through /bin/sh so a lost executable bit or shebang cannot stop startup. | |
| CMD ["/bin/sh", "/app/docker-entrypoint.sh"] | |