Spaces:
Sleeping
Sleeping
| FROM node:22.22.0-slim AS base | |
| RUN corepack enable && corepack prepare pnpm@latest --activate | |
| WORKDIR /app | |
| FROM base AS deps | |
| # Copy only dependency manifests first for better layer caching | |
| COPY package.json ./ | |
| COPY pnpm-lock.yaml* ./ | |
| # better-sqlite3 requires native compilation tools | |
| RUN apt-get update && apt-get install -y python3 make g++ --no-install-recommends && rm -rf /var/lib/apt/lists/* | |
| RUN if [ -f pnpm-lock.yaml ]; then \ | |
| pnpm install --frozen-lockfile; \ | |
| else \ | |
| echo "WARN: pnpm-lock.yaml not found in build context; running non-frozen install" && \ | |
| pnpm install --no-frozen-lockfile; \ | |
| fi | |
| FROM base AS build | |
| COPY --from=deps /app/node_modules ./node_modules | |
| COPY . . | |
| RUN pnpm build | |
| FROM node:22.22.0-slim AS runtime | |
| ARG MC_VERSION=dev | |
| LABEL org.opencontainers.image.source="https://github.com/openclaw/mission-control" | |
| LABEL org.opencontainers.image.description="Mission Control - operations dashboard" | |
| LABEL org.opencontainers.image.licenses="MIT" | |
| LABEL org.opencontainers.image.version="${MC_VERSION}" | |
| WORKDIR /app | |
| ENV NODE_ENV=production | |
| # Python + huggingface_hub for HF Dataset persistence | |
| RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip \ | |
| && pip3 install --no-cache-dir --break-system-packages huggingface_hub \ | |
| && apt-get purge -y python3-pip && apt-get autoremove -y \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs | |
| COPY --from=build /app/.next/standalone ./ | |
| COPY --from=build /app/.next/static ./.next/static | |
| COPY --from=build /app/public ./public | |
| # Copy schema.sql needed by migration 001_init at runtime | |
| COPY --from=build /app/src/lib/schema.sql ./src/lib/schema.sql | |
| # Create data directory with correct ownership for SQLite | |
| RUN mkdir -p .data && chown nextjs:nodejs .data | |
| RUN echo 'const http=require("http");const r=http.get("http://localhost:"+(process.env.PORT||3000)+"/api/status?action=health",s=>{process.exit(s.statusCode===200?0:1)});r.on("error",()=>process.exit(1));r.setTimeout(4000,()=>{r.destroy();process.exit(1)})' > /app/healthcheck.js | |
| COPY docker-entrypoint.sh /app/docker-entrypoint.sh | |
| COPY hf-persist.py /app/hf-persist.py | |
| RUN chmod +x /app/docker-entrypoint.sh | |
| USER nextjs | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| ENV HOSTNAME=0.0.0.0 | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ | |
| CMD ["node", "/app/healthcheck.js"] | |
| ENTRYPOINT ["/app/docker-entrypoint.sh"] | |