chore: update Docker and CI for web + backend architecture
Build and Deploy / Build & Push (push) Successful in 2m10s
Build and Deploy / Build & Push (push) Successful in 2m10s
Replace scraper container with backend API container. Web image no longer mounts a data volume or ships SQLite. Backend image runs Hono server with node-cron scheduler, owns the database exclusively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ node_modules
|
|||||||
data/*.db
|
data/*.db
|
||||||
data/*.db-shm
|
data/*.db-shm
|
||||||
data/*.db-wal
|
data/*.db-wal
|
||||||
|
backend/data
|
||||||
.env*
|
.env*
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar:web
|
tags: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar:web
|
||||||
|
|
||||||
- name: Build and push scraper image
|
- name: Build and push backend image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
target: scraper
|
target: backend
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar:scraper
|
tags: ${{ vars.REGISTRY }}/${{ gitea.repository_owner }}/sixflagssupercalendar:backend
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ yarn-error.log*
|
|||||||
/data/*.db
|
/data/*.db
|
||||||
/data/*.db-shm
|
/data/*.db-shm
|
||||||
/data/*.db-wal
|
/data/*.db-wal
|
||||||
|
/backend/data/
|
||||||
parks.db
|
parks.db
|
||||||
|
|
||||||
# env files
|
# env files
|
||||||
|
|||||||
+24
-32
@@ -1,19 +1,21 @@
|
|||||||
# Stage 1: Install all dependencies (dev included — scraper needs tsx + playwright)
|
# ── builder: Next.js production build ────────────────────────────────────────
|
||||||
FROM node:22-bookworm-slim AS deps
|
FROM node:22-bookworm-slim AS builder
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Stage 2: Build the Next.js app
|
|
||||||
FROM deps AS builder
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# ── backend-deps: backend node_modules (better-sqlite3 needs build tools) ────
|
||||||
|
FROM node:22-bookworm-slim AS backend-deps
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
WORKDIR /app
|
||||||
|
COPY backend/package.json backend/package-lock.json* ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
# ── web ──────────────────────────────────────────────────────────────────────
|
# ── web ──────────────────────────────────────────────────────────────────────
|
||||||
# Minimal Next.js runner. No playwright, no tsx, no scripts.
|
# Minimal Next.js standalone runner. No database, no native modules.
|
||||||
# next build --output standalone bundles its own node_modules (incl. better-sqlite3).
|
|
||||||
FROM node:22-bookworm-slim AS web
|
FROM node:22-bookworm-slim AS web
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -27,44 +29,34 @@ 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/.next/static ./.next/static
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||||
|
|
||||||
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
|
|
||||||
VOLUME ["/app/data"]
|
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
ENV HOSTNAME="0.0.0.0"
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|
||||||
# ── scraper ───────────────────────────────────────────────────────────────────
|
# ── backend ──────────────────────────────────────────────────────────────────
|
||||||
# Scraper-only image. No Next.js output. Runs on a nightly schedule via
|
# Hono API server + node-cron scheduler. Owns the SQLite database exclusively.
|
||||||
# scripts/scrape-schedule.sh. Staleness windows are configurable via env vars:
|
FROM node:22-bookworm-slim AS backend
|
||||||
# PARK_HOURS_STALENESS_HOURS (default: 72)
|
|
||||||
# COASTER_STALENESS_HOURS (default: 720 = 30 days)
|
|
||||||
FROM node:22-bookworm-slim AS scraper
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PLAYWRIGHT_BROWSERS_PATH=/app/.playwright
|
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs && \
|
RUN addgroup --system --gid 1001 nodejs && \
|
||||||
adduser --system --uid 1001 nextjs
|
adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/scripts ./scripts
|
COPY --from=backend-deps --chown=nextjs:nodejs /app/node_modules ./backend/node_modules
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/lib ./lib
|
COPY --chown=nextjs:nodejs backend/src ./backend/src
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/tests ./tests
|
COPY --chown=nextjs:nodejs backend/package.json ./backend/package.json
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
COPY --chown=nextjs:nodejs backend/tsconfig.json ./backend/tsconfig.json
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/tsconfig.json ./tsconfig.json
|
COPY --chown=nextjs:nodejs lib ./lib
|
||||||
|
|
||||||
# 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
|
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
|
||||||
VOLUME ["/app/data"]
|
VOLUME ["/app/data"]
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
CMD ["sh", "/app/scripts/scrape-schedule.sh"]
|
EXPOSE 3001
|
||||||
|
ENV PORT=3001
|
||||||
|
|
||||||
|
WORKDIR /app/backend
|
||||||
|
CMD ["npx", "tsx", "src/index.ts"]
|
||||||
|
|||||||
+5
-5
@@ -3,21 +3,21 @@ services:
|
|||||||
image: gitea.thewrightserver.net/josh/sixflagssupercalendar:web
|
image: gitea.thewrightserver.net/josh/sixflagssupercalendar:web
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
volumes:
|
|
||||||
- park_data:/app/data
|
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
|
- BACKEND_URL=http://backend:3001
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
scraper:
|
backend:
|
||||||
image: gitea.thewrightserver.net/josh/sixflagssupercalendar:scraper
|
image: gitea.thewrightserver.net/josh/sixflagssupercalendar:backend
|
||||||
|
ports:
|
||||||
|
- "3001:3001"
|
||||||
volumes:
|
volumes:
|
||||||
- park_data:/app/data
|
- park_data:/app/data
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- TZ=America/New_York
|
- TZ=America/New_York
|
||||||
- PARK_HOURS_STALENESS_HOURS=72
|
- PARK_HOURS_STALENESS_HOURS=72
|
||||||
- COASTER_STALENESS_HOURS=720
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user