OCR_DATASET_MAKER / web /Dockerfile
Omarrran's picture
OCR Dataset Generator for HF Spaces
24a732c
# Multi-stage build for Next.js on Hugging Face Spaces
FROM node:20-alpine AS base
# Dependencies stage
FROM base AS deps
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Builder stage
FROM base AS builder
WORKDIR /app
# Copy dependencies
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Disable telemetry during build
ENV NEXT_TELEMETRY_DISABLED=1
# Build the application
RUN npm run build
# Runner stage
FROM base AS runner
WORKDIR /app
# Set production environment
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Create data directory for HF Spaces persistent storage
RUN mkdir -p /data && chmod 777 /data
ENV DATA_DIR=/data
# Copy built assets from builder
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# HF Spaces uses port 7860
EXPOSE 7860
ENV PORT=7860
ENV HOSTNAME="0.0.0.0"
# Start the server
CMD ["node", "server.js"]