Files
HOA_Financial_Platform/backend/Dockerfile
olsch01 1dc3353e6e feat: dynamic app version sourced from root VERSION file
Replaces the hardcoded version string in SettingsPage.tsx with a single
source of truth: a /VERSION file at the repo root. To cut a new release,
edit only that one file.

Frontend:
- vite.config.ts reads /VERSION at dev-server startup and injects it as
  the __APP_VERSION__ global via Vite's define mechanism (compile-time,
  zero runtime cost). Falls back to VITE_APP_VERSION env var for prod
  Docker builds that pass it as a build arg.
- vite-env.d.ts adds the TypeScript declaration for __APP_VERSION__.
- SettingsPage.tsx Badge now renders {__APP_VERSION__} instead of the
  literal string.

Backend:
- app.controller.ts reads /VERSION once at module load and includes
  "version" in both GET /api and GET /api/health responses.
- NewRelicTransactionInterceptor tags every NR transaction with
  newrelic.addCustomAttribute('appVersion', version) so releases can be
  compared in NRQL: SELECT average(duration) FROM Transaction WHERE
  appVersion = '2026.5.22'

Docker:
- docker-compose.yml mounts ./VERSION:/app/VERSION:ro in both backend
  and frontend dev containers.
- Production Dockerfiles include COPY VERSION ./ with a comment
  instructing CI to copy the root VERSION into each build context before
  docker build.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 10:03:44 -04:00

37 lines
1.1 KiB
Docker

# ---- Production Dockerfile for NestJS backend ----
# Multi-stage build: compile TypeScript, then run with minimal image
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# VERSION must be copied into the build context before `docker build`.
# In CI / deploy scripts run: cp VERSION backend/VERSION (or pass --build-arg)
COPY VERSION ./
RUN npm run build
# Stage 2: Production
FROM node:20-alpine
WORKDIR /app
# Only install production dependencies
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy compiled output, New Relic preload, and VERSION from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/newrelic-preload.js ./newrelic-preload.js
COPY --from=builder /app/VERSION ./VERSION
# New Relic agent — configured entirely via environment variables
ENV NEW_RELIC_NO_CONFIG_FILE=true
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
ENV NEW_RELIC_LOG=stdout
EXPOSE 3000
# Preload the New Relic agent (activates only when NEW_RELIC_ENABLED=true)
CMD ["node", "-r", "./newrelic-preload.js", "dist/main"]