Spaces:
Sleeping
Sleeping
File size: 1,866 Bytes
ea8dde3 3ff6ff5 ea8dde3 | 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 63 64 65 66 67 68 69 70 71 72 | # ============================================
# Stage 1: Install dependencies
# ============================================
FROM node:20-slim AS dependencies
WORKDIR /app
# Install build tools needed for better-sqlite3 native compilation
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci
# ============================================
# Stage 2: Build the Next.js application
# ============================================
FROM node:20-slim AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Seed the database at build time so the image ships with data.
# The seed script creates ./data/crm.db if it does not exist.
RUN npx tsx src/lib/db/seed.ts
RUN npm run build
# ============================================
# Stage 3: Production runner
# ============================================
FROM node:20-slim AS runner
LABEL org.opencontainers.image.source=https://github.com/McGill-NLP/webarena-pro
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Copy public assets (not included in standalone output)
COPY --from=builder --chown=node:node /app/public ./public
# Create .next directory owned by node for prerender cache
RUN mkdir -p .next && chown node:node .next
# Copy standalone server + static assets
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
# Copy the seeded SQLite database
COPY --from=builder --chown=node:node /app/data ./data
# HF Spaces runs containers as UID 1000.
# The node user in official Node images is already UID 1000.
USER node
EXPOSE 3000
CMD ["node", "server.js"]
|