Files
SixFlagsSuperCalendar/Dockerfile
josh eeb4a649c1
All checks were successful
Build and Deploy / Build & Push (push) Successful in 3m4s
feat: split web and scraper into separate Docker images
- Dockerfile: replace single runner stage with web + scraper named targets
  - web: Next.js standalone only — no playwright, tsx, or scripts
  - scraper: scripts/lib/node_modules/playwright only — no Next.js output
- docker-compose.yml: each service pulls its dedicated image tag
- .gitea/workflows/deploy.yml: build both targets on push to main
- lib/db.ts: STALE_AFTER_MS reads PARK_HOURS_STALENESS_HOURS env var (default 72h)
- lib/park-meta.ts: COASTER_STALE_MS reads COASTER_STALENESS_HOURS env var (default 720h)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 16:40:31 -04:00

71 lines
2.7 KiB
Docker

# Stage 1: Install all dependencies (dev included — scraper needs tsx + playwright)
FROM node:22-bookworm-slim AS deps
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
# Stage 2: Build the Next.js app
FROM deps AS builder
COPY . .
RUN npm run build
# ── web ──────────────────────────────────────────────────────────────────────
# Minimal Next.js runner. No playwright, no tsx, no scripts.
# next build --output standalone bundles its own node_modules (incl. better-sqlite3).
FROM node:22-bookworm-slim AS web
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
VOLUME ["/app/data"]
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
# ── scraper ───────────────────────────────────────────────────────────────────
# Scraper-only image. No Next.js output. Runs on a nightly schedule via
# scripts/scrape-schedule.sh. Staleness windows are configurable via env vars:
# PARK_HOURS_STALENESS_HOURS (default: 72)
# COASTER_STALENESS_HOURS (default: 720 = 30 days)
FROM node:22-bookworm-slim AS scraper
WORKDIR /app
ENV NODE_ENV=production
ENV PLAYWRIGHT_BROWSERS_PATH=/app/.playwright
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder --chown=nextjs:nodejs /app/scripts ./scripts
COPY --from=builder --chown=nextjs:nodejs /app/lib ./lib
COPY --from=builder --chown=nextjs:nodejs /app/tests ./tests
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/tsconfig.json ./tsconfig.json
# Full node_modules — includes tsx, playwright, better-sqlite3, all devDeps
COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules
# Install Playwright Chromium + system libraries (runs as root, then fixes ownership)
RUN npx playwright install --with-deps chromium && \
chown -R nextjs:nodejs /app/.playwright
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
VOLUME ["/app/data"]
USER nextjs
CMD ["sh", "/app/scripts/scrape-schedule.sh"]