File size: 1,977 Bytes
827d82d a59f28c 827d82d 4fc4120 a59f28c e4884cd a59f28c 827d82d a59f28c f68d61b a59f28c 1adb7ee 827d82d 4fc4120 a59f28c 222146f 8fde072 222146f 752165b f9ed63f 752165b e4884cd | 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 | FROM node:20-bookworm-slim
WORKDIR /app
# Set Puppeteer vars to skip direct download and use system Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
# Install System dependencies: Chromium (for Puppeteer), OpenSSL (for Prisma), and CA certs
RUN apt-get update && apt-get install -y \
chromium \
openssl \
ca-certificates \
curl \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Install pnpm (Pinned to v9 to avoid ERR_INVALID_THIS fetch bug on Node 20) and Typescript
RUN npm install -g pnpm@9 typescript tsx
# Copy ALL workspace files first for a proper pnpm install
COPY package.json pnpm-workspace.yaml ./
COPY packages/ packages/
COPY apps/ apps/
COPY scripts/ scripts/
# Install all dependencies
RUN pnpm install
# Generate Prisma Client
RUN pnpm --filter @repo/database generate
# Give Node more memory and force IPv4 DNS resolution (fixes ENOTFOUND in native fetch)
ENV NODE_OPTIONS="--max-old-space-size=2048 --dns-result-order=ipv4first"
# Build all packages and apps to ensure dist folders are populated
RUN pnpm -r build
# Expose port (HF Spaces uses 7860)
EXPOSE 7860
ENV PORT=7860
# Force Docker cache invalidation - bump date to trigger clean rebuild
ENV REBUILD_DATE="2026-03-01-v14-fix-day-increment"
# SAFETY: Default to skipping DB push to prevent schema drift.
# Only Railway (api service) should push schema — it overrides SKIP_DB_PUSH=false in its variables.
# HF Space (gateway) MUST NOT push — it would drop columns added by Railway migrations.
ENV SKIP_DB_PUSH=true
# Sync DB schema only if DATABASE_URL is present and NOT on a gateway-only light node
CMD ["sh", "-c", "if [ -n \"$DATABASE_URL\" ] && [ \"$SKIP_DB_PUSH\" != \"true\" ]; then echo '[STARTUP] Syncing DB schema...'; pnpm --filter @repo/database db:push --accept-data-loss; else echo '[STARTUP] Skipping DB Push (SKIP_DB_PUSH=true or no DATABASE_URL)'; fi && tsx apps/api/src/index.ts"]
|