From f52605289b566478f429848a793806471e18aa62 Mon Sep 17 00:00:00 2001 From: iconoclast hero Date: Fri, 3 Oct 2025 09:33:43 -0400 Subject: [PATCH] Patch logger for ISO8601 TZ offsets and fix Docker build - server/logger.ts: timestamps now use local TZ offset instead of Z - Dockerfile: replaced 'npm ci --omit=dev' with 'npm install --omit=dev' to fix Alpine build failure - References discussion: https://github.com/orgs/fosrl/discussions/1025 - Note: timestamps default to +00:00 (UTC) unless the user sets environment: TZ= in docker-compose.yaml Optional future improvement: include tzdata in the container for shell/date consistency. --- Dockerfile | 4 +++- server/logger.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b293ae42..a48e4a1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,9 @@ RUN apk add --no-cache curl # COPY package.json package-lock.json ./ COPY package*.json ./ -#RUN npm ci --omit=dev && npm cache clean --force + +# 'npm ci --omit=dev' with 'npm install --omit=dev' to fix Alpine build failure +# RUN npm ci --omit=dev && npm cache clean --force RUN npm install --omit=dev && npm cache clean --force COPY --from=builder /app/.next/standalone ./ diff --git a/server/logger.ts b/server/logger.ts index 1c20b3f8..6d3a539b 100644 --- a/server/logger.ts +++ b/server/logger.ts @@ -6,6 +6,7 @@ import { APP_PATH } from "./lib/consts"; import telemetryClient from "./lib/telemetry"; // helper to get ISO8601 string in the TZ from process.env.TZ +// This replaces the default Z (UTC) with the local offset from process.env.TZ const isoLocal = () => { const tz = process.env.TZ || "UTC"; const d = new Date(); @@ -15,6 +16,8 @@ const isoLocal = () => { const pad = (n: number) => String(n).padStart(2, "0"); const hours = pad(Math.floor(Math.abs(tzOffsetMin) / 60)); const mins = pad(Math.abs(tzOffsetMin) % 60); + + // Replace Z in ISO string with local offset return s.replace(" ", "T") + `${sign}${hours}:${mins}`; }; @@ -74,6 +77,8 @@ const logger = winston.createLogger({ winston.format.errors({ stack: true }), winston.format.colorize(), winston.format.splat(), + + // Use isoLocal so timestamps respect TZ env, not just UTC winston.format.timestamp({ format: isoLocal }), hformat ),