`apps/web/vite.config.ts` now injects three build-time constants via
`define`: `__APP_VERSION__` (root package.json), `__APP_COMMIT__`
(GIT_SHA env > local `git rev-parse` > 'dev'), `__BUILD_TIME__` (ISO
timestamp at build). They're declared in `apps/web/src/global.d.ts`
and re-exported through `$lib/version` — components consume the named
exports rather than the magic globals so an accidental tree-shake
would break the test, not the page silently.
`/settings` gains an "About" section at the bottom: a small chip
`v{version} · {commit} · {date}` in muted text. Not interactive,
purely diagnostic — useful when a user reports a bug from a stale
PWA install.
Deploy pipeline:
- `apps/web/Dockerfile` accepts a `GIT_SHA` build arg and exports
it as an env var for the SvelteKit build step.
- `infra/docker-compose.erosi.yml` forwards `${GIT_SHA:-dev}` into
the build args.
- `infra/scripts/deploy-erosi.sh` captures `git rev-parse --short
HEAD` locally (the deploy host has .git; the remote doesn't —
rsync excludes it) and forwards it via `ssh ... env GIT_SHA=…`
so the remote `docker compose build` sees it.
V-01/V-02 vitest: stub the three globals via `vi.stubGlobal` (vitest
doesn't run through the main vite.config so `define` isn't applied),
assert the named exports thread through and never collapse to
undefined or the 'dev' sentinel under a real build.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
2.3 KiB
Docker
62 lines
2.3 KiB
Docker
# Multi-stage build for the SvelteKit Node.js server
|
|
# Build args map to PUBLIC_* env vars baked at build time (SvelteKit requires this)
|
|
|
|
FROM node:22-alpine AS base
|
|
RUN corepack enable pnpm
|
|
|
|
# ── Dependencies ──────────────────────────────────────────────────────────────
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
|
|
COPY apps/web/package.json ./apps/web/
|
|
COPY packages/types/package.json ./packages/types/
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# ── Build ─────────────────────────────────────────────────────────────────────
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
|
|
ARG PUBLIC_SUPABASE_URL
|
|
ARG PUBLIC_SUPABASE_ANON_KEY
|
|
ARG PUBLIC_KEYCLOAK_URL
|
|
ARG PUBLIC_KEYCLOAK_REALM
|
|
ARG PUBLIC_KEYCLOAK_CLIENT_ID
|
|
ARG PUBLIC_APP_URL
|
|
# Fase 14.3.5 — short git sha of the deploy. Surfaced in /settings via
|
|
# `$lib/version`. Optional: when unset the build falls back to `git
|
|
# rev-parse` (only works if .git is in the build context) and then to
|
|
# the literal 'dev'.
|
|
ARG GIT_SHA
|
|
|
|
ENV PUBLIC_SUPABASE_URL=$PUBLIC_SUPABASE_URL
|
|
ENV PUBLIC_SUPABASE_ANON_KEY=$PUBLIC_SUPABASE_ANON_KEY
|
|
ENV PUBLIC_KEYCLOAK_URL=$PUBLIC_KEYCLOAK_URL
|
|
ENV PUBLIC_KEYCLOAK_REALM=$PUBLIC_KEYCLOAK_REALM
|
|
ENV PUBLIC_KEYCLOAK_CLIENT_ID=$PUBLIC_KEYCLOAK_CLIENT_ID
|
|
ENV PUBLIC_APP_URL=$PUBLIC_APP_URL
|
|
ENV GIT_SHA=$GIT_SHA
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
|
COPY . .
|
|
|
|
RUN pnpm --filter @colectivo/types build 2>/dev/null || true
|
|
RUN pnpm --filter @colectivo/web build
|
|
|
|
# ── Runtime ───────────────────────────────────────────────────────────────────
|
|
FROM node:22-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
|
|
# Only copy the compiled output
|
|
COPY --from=builder /app/apps/web/build ./build
|
|
COPY --from=builder /app/apps/web/package.json ./
|
|
|
|
# Install production-only deps for the Node adapter
|
|
RUN npm install --omit=dev --ignore-scripts 2>/dev/null || true
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "build"]
|