Spaces:
Running
Running
File size: 1,154 Bytes
2f53b74 88b6846 2f53b74 88b6846 2f53b74 88b6846 2f53b74 88b6846 |
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 |
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
# Copy package.json and package-lock.json
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Set environment variable for build
ENV NEXT_TELEMETRY_DISABLED=1
# Build the application
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copy public folder
COPY --from=builder /app/public ./public
# Copy built application
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Create /data directory for HF Spaces persistent storage
RUN mkdir -p /data && chmod 777 /data
# Create local dataset directory as fallback
RUN mkdir -p /app/dataset && chmod 777 /app/dataset
# Set default data directory
ENV DATA_DIR=/data
# HF Spaces uses port 7860 by default
EXPOSE 7860
ENV PORT=7860
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
|