Spaces:
Runtime error
Runtime error
| # Base image | |
| FROM node:20-alpine AS builder | |
| RUN apk add --no-cache openssl | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| COPY prisma ./prisma/ | |
| RUN npm ci | |
| COPY . . | |
| RUN npm run prisma:generate | |
| RUN npm run build | |
| # Production image - fully compliant with Hugging Face Spaces security | |
| FROM node:20-alpine AS runner | |
| RUN apk add --no-cache openssl | |
| WORKDIR /app | |
| # Copy built files and set permissions for node user (UID 1000) | |
| COPY --from=builder --chown=node:node /app/package*.json ./ | |
| COPY --from=builder --chown=node:node /app/node_modules ./node_modules | |
| COPY --from=builder --chown=node:node /app/dist ./dist | |
| COPY --from=builder --chown=node:node /app/prisma ./prisma | |
| # Create data directory for SQLite database with proper owner permissions | |
| RUN mkdir -p /app/data && chown -R node:node /app/data | |
| # Run as non-root user (required by Hugging Face Spaces) | |
| USER node | |
| # Hugging Face Spaces expects the container to run on port 7860 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Run migrations and start the server | |
| CMD ["sh", "-c", "npx prisma migrate deploy && node dist/main.js"] | |