Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
63 lines
3.2 KiB
Docker
63 lines
3.2 KiB
Docker
FROM node:24-alpine AS base
|
|
|
|
# ── Stage 1: install deps ─────────────────────────────────────────────────────
|
|
FROM base AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
COPY vendor/ ./vendor/
|
|
RUN npm ci
|
|
# A High or Critical advisory in a runtime dependency fails the image (F45). Dev tooling is not shipped,
|
|
# so it is excluded. Moderate advisories do not block; review them with a full `npm audit`.
|
|
RUN npm audit --omit=dev --audit-level=high
|
|
|
|
# ── Stage 2: source shared by test and build ─────────────────────────────────
|
|
FROM base AS source
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# ── Stage 3a: test ────────────────────────────────────────────────────────────
|
|
# Tests run here deliberately: a red suite fails the image build, matching
|
|
# solvway-customer-portal. The Maven modules are built with -Dmaven.test.skip=true and
|
|
# not covered in CI, so this is the only automated gate this module gets.
|
|
# .dockerignore must therefore NOT exclude test/ or *.test.ts(x) — vitest.config.ts
|
|
# aliases `server-only` to test/stub-empty.ts.
|
|
# BuildKit runs this stage in parallel with builder, and builds only stages the target needs: the
|
|
# runner's COPY of .tests-passed is what keeps this suite a gate. Do not remove it.
|
|
FROM source AS test
|
|
# ci-runs-repo-checks: an ESLint error fails the image like a red test (warnings do not).
|
|
RUN npm run lint && npm run test && touch .tests-passed
|
|
|
|
# ── Stage 3b: build ───────────────────────────────────────────────────────────
|
|
FROM source AS builder
|
|
# Delete Next's build cache in the same RUN so it never lands in a committed layer. Nothing reads it: the
|
|
# build starts from a clean .next (.dockerignore) and the runner copies only standalone/, static/ and public/.
|
|
# Left in, Turbopack's churning .sst store made Docker fail to apply the layer (main run 5980:
|
|
# "failed to Lchown .../.next/cache/turbopack/...sst: no such file").
|
|
RUN npm run build && rm -rf .next/cache
|
|
|
|
# ── Stage 4: runtime image ────────────────────────────────────────────────────
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
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
|
|
# Depends on the test stage so a red suite fails the image (see Stage 3a).
|
|
COPY --from=test /app/.tests-passed /tmp/.tests-passed
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
# Supply MOBILE_API_BASE_URL, MOBILE_API_KEY and SESSION_COOKIE_NAME at runtime
|
|
# via -e flags / k8s env — never bake secrets into the image
|
|
CMD ["node", "server.js"]
|