Spaces:
Build error
Build error
File size: 1,594 Bytes
a2ae296 741ff99 a2ae296 741ff99 a2ae296 741ff99 a2ae296 741ff99 a2ae296 741ff99 a2ae296 c9da1f2 a2ae296 c9da1f2 a2ae296 | 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 node:22-slim AS base
# Install OpenSSL for Prisma + build tools for native modules
RUN apt-get update && apt-get install -y openssl python3 make g++ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install dependencies
FROM base AS deps
COPY package.json package-lock.json ./
RUN npm ci
# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma client
RUN npx prisma generate
# Build Next.js
RUN npm run build
# Production image
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Use the existing 'node' user (uid 1000) that comes with the node image
# HF Spaces also runs as uid 1000, so this is compatible
# Copy necessary files
COPY --from=builder /app/public ./public
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
COPY --from=builder /app/generated ./generated
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
# Create data directory for SQLite with correct permissions
RUN mkdir -p /app/data && chown node:node /app/data
USER node
# HF Spaces expects port 7860
EXPOSE 7860
ENV PORT=7860
ENV HOSTNAME="0.0.0.0"
ENV DATABASE_URL="file:/app/data/prod.db"
CMD ["sh", "-c", "npx prisma db push --skip-generate && node server.js"]
|