File size: 2,314 Bytes
4859586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
# ══════════════════════════════════════════════════════════════
# Kafe Nusantara — Hugging Face Space Dockerfile
# ══════════════════════════════════════════════════════════════
#
# This is a lightweight version for HF Spaces that runs the
# Next.js app in demo/static mode. The full infrastructure
# (PostgreSQL, Qdrant, Ollama, TEI) should be run locally
# or on a proper cloud setup.
#
# For HF Spaces, this builds and serves the Next.js app
# with demo/mock data (no external services required).
# ══════════════════════════════════════════════════════════════

FROM node:20-alpine AS base

# ── Stage 1: Install dependencies ────────────────────────────
FROM base AS deps
WORKDIR /app

COPY package.json package-lock.json* ./
RUN npm ci --legacy-peer-deps || npm install --legacy-peer-deps

# ── Stage 2: Build ───────────────────────────────────────────
FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Build-time environment variables for demo mode
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production

# Skip DB-dependent build steps
ENV SKIP_DB_CHECK=true

RUN npm run build

# ── Stage 3: Production ─────────────────────────────────────
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

# Create non-root user (HF Spaces requirement)
RUN addgroup --system --gid 1001 nodejs && \
    adduser --system --uid 1001 nextjs

# Copy build output
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

CMD ["node", "server.js"]