Round 4: regressions fixed + mobile standard
Part A — Round 3 regressions:
- A.1: verify-cost-reconciliation.mjs now loads .env.local, wraps in try/catch, exits 1 on any failure
- A.2: Vehicle Costs restored Santam — back to R 14,996.31 (matches row-by-row sum)
- A.3: incl<excl / VAT math / VAT>20% now FATAL — seed exits 2 with full report (4 anomalies on Charl-CCS + Buildsmart)
- A.4: Reconciliation target R 694,962.93 with both deltas itemised (Personnel +R19,800, Santam -R5,322.44, unexplained R 0.00)
- A.5: 'Lines' view uses actual lines (recharts LineChart), no fills; fills only in 'Cost stack'
Part B — Mobile standard:
- B.1: header wraps to 2 rows on mobile; YTD badge cards stack; page-wide overflow eliminated on /income, /charts, /overheads, /running, /expenses
- B.2: IncomeView card row layout stacked — name gets its own line on mobile, never truncated to single char
- B.3: Plant type filter is a <select> dropdown below lg (was 18 pills wrapping to 13 rows); same for sort on /income and /running
- B.4: Plant table first column sticky; -webkit-overflow-scrolling: touch; tables scroll inside their own container
- B.5: All buttons/links use min-h-[44px] tap targets; text below 12px is bumped where it matters
- B.6: Charts legend wraps below title; chart min-height h-44 → h-52 on mobile
- B.7: paddingTop env(safe-area-inset-top) on sticky header for notch/home indicator clearance
AGENTS.md created with the standing mobile checklist rule.
2026-09-12 10:05:43 +00:00
|
|
|
# syntax=docker/dockerfile:1.7
|
|
|
|
|
#
|
|
|
|
|
# Production image for MEGA PLANT — designed for Coolify.
|
|
|
|
|
#
|
|
|
|
|
# Multi-stage build:
|
|
|
|
|
# 1. deps — fetch and cache npm dependencies
|
|
|
|
|
# 2. builder — compile the Next.js standalone bundle
|
|
|
|
|
# 3. runner — minimal runtime image with just the standalone server
|
|
|
|
|
#
|
|
|
|
|
# The container listens on ${PORT:-3000} and binds 0.0.0.0 so Coolify's
|
|
|
|
|
# Traefik proxy can reach it. /api/health is the liveness probe.
|
|
|
|
|
#
|
|
|
|
|
# IMPORTANT — NEXT_PUBLIC_PB_URL must be passed as a BUILD ARG, not just a
|
|
|
|
|
# runtime variable. Next.js inlines NEXT_PUBLIC_* into the client bundle at
|
|
|
|
|
# build time; setting it only at runtime leaves the browser pointing at
|
|
|
|
|
# whatever was baked in. See COOLIFY.md.
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# 1. deps
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
FROM node:20-alpine AS deps
|
|
|
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy only the manifest + lockfile so this layer stays cached for as long
|
|
|
|
|
# as dependencies don't change.
|
|
|
|
|
COPY package.json package-lock.json* ./
|
|
|
|
|
RUN npm ci --no-audit --no-fund
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# 2. builder
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
FROM node:20-alpine AS builder
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# The PocketBase URL is compiled into the client bundle here. Fail loudly
|
|
|
|
|
# rather than shipping an image that silently talks to the wrong database.
|
|
|
|
|
ARG NEXT_PUBLIC_PB_URL
|
|
|
|
|
ENV NEXT_PUBLIC_PB_URL=${NEXT_PUBLIC_PB_URL}
|
|
|
|
|
RUN test -n "$NEXT_PUBLIC_PB_URL" \
|
|
|
|
|
|| (echo "" \
|
|
|
|
|
&& echo "ERROR: build arg NEXT_PUBLIC_PB_URL is required." \
|
|
|
|
|
&& echo " Coolify -> Build -> Build Arguments -> NEXT_PUBLIC_PB_URL=https://pb.mega.plant.example" \
|
|
|
|
|
&& echo " Local: docker build --build-arg NEXT_PUBLIC_PB_URL=https://... ." \
|
|
|
|
|
&& echo "" && exit 1)
|
|
|
|
|
|
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
|
|
|
|
|
# `next build --webpack` is deliberate: @ducanh2912/next-pwa is Webpack-only
|
|
|
|
|
# and is what generates public/sw.js + public/workbox-*.js. Dropping the flag
|
|
|
|
|
# silently ships an app with no service worker and no offline install.
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# 3. runner
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
FROM node:20-alpine AS runner
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
|
ENV PORT=3000
|
|
|
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
|
|
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
|
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
|
|
|
|
|
|
# Static assets — includes the manifest, icons, and the service worker that
|
|
|
|
|
# next-pwa generated during the build.
|
|
|
|
|
COPY --from=builder /app/public ./public
|
|
|
|
|
|
|
|
|
|
# `output: "standalone"` produces server.js plus a trimmed node_modules, but
|
|
|
|
|
# does NOT include .next/static — that has to be copied in separately.
|
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
|
|
2026-10-06 08:49:10 +00:00
|
|
|
# Next's output tracer cannot see pdfjs-dist's worker. The only reference to it
|
|
|
|
|
# is a createRequire(...).resolve() call, which the tracer does not follow, so
|
|
|
|
|
# the standalone bundle ships pdf.mjs WITHOUT pdf.worker.mjs — and every parse
|
|
|
|
|
# then dies with "Setting up fake worker failed: Cannot find module
|
|
|
|
|
# '/app/node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs'". Copy the package
|
|
|
|
|
# in whole: the worker has to sit next to pdf.mjs at runtime, and so do the
|
|
|
|
|
# standard fonts, which the parser needs because it passes useSystemFonts.
|
|
|
|
|
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/pdfjs-dist ./node_modules/pdfjs-dist
|
|
|
|
|
|
Round 4: regressions fixed + mobile standard
Part A — Round 3 regressions:
- A.1: verify-cost-reconciliation.mjs now loads .env.local, wraps in try/catch, exits 1 on any failure
- A.2: Vehicle Costs restored Santam — back to R 14,996.31 (matches row-by-row sum)
- A.3: incl<excl / VAT math / VAT>20% now FATAL — seed exits 2 with full report (4 anomalies on Charl-CCS + Buildsmart)
- A.4: Reconciliation target R 694,962.93 with both deltas itemised (Personnel +R19,800, Santam -R5,322.44, unexplained R 0.00)
- A.5: 'Lines' view uses actual lines (recharts LineChart), no fills; fills only in 'Cost stack'
Part B — Mobile standard:
- B.1: header wraps to 2 rows on mobile; YTD badge cards stack; page-wide overflow eliminated on /income, /charts, /overheads, /running, /expenses
- B.2: IncomeView card row layout stacked — name gets its own line on mobile, never truncated to single char
- B.3: Plant type filter is a <select> dropdown below lg (was 18 pills wrapping to 13 rows); same for sort on /income and /running
- B.4: Plant table first column sticky; -webkit-overflow-scrolling: touch; tables scroll inside their own container
- B.5: All buttons/links use min-h-[44px] tap targets; text below 12px is bumped where it matters
- B.6: Charts legend wraps below title; chart min-height h-44 → h-52 on mobile
- B.7: paddingTop env(safe-area-inset-top) on sticky header for notch/home indicator clearance
AGENTS.md created with the standing mobile checklist rule.
2026-09-12 10:05:43 +00:00
|
|
|
USER nextjs
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
|
|
|
CMD wget -q --spider http://127.0.0.1:3000/api/health || exit 1
|
|
|
|
|
|
|
|
|
|
CMD ["node", "server.js"]
|