Spaces:
Sleeping
Sleeping
File size: 2,461 Bytes
b6ecafa b608851 679f2be d8f73c7 679f2be a2745d4 d8f73c7 679f2be d8f73c7 b608851 679f2be b608851 b6ecafa b608851 123e7c1 b608851 932b27c 679f2be 8bdb2e3 b6ecafa 943fe08 123e7c1 943fe08 b608851 7e0fa81 8bdb2e3 959f8d7 b6ecafa 943fe08 | 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 | 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"]
|