From 02301ff1725623b5ff9f764fd9b38ef399769761 Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 30 Oct 2026 16:10:07 +0100 Subject: [PATCH] u --- Dockerfile | 3 ++- docs/api/routes-all.md | 2 +- docs/api/routes/auth/me.md | 4 +++- docs/dash.sh | 1 + src/api/auth/meJson.js | 2 ++ src/api/routes/auth/me.js | 12 ++++++++++++ src/config/env.js | 9 +++++++-- 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5934831..64ea54c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,8 @@ COPY --from=syslibs /usr/lib/x86_64-linux-gnu/libfontconfig.so* /usr/lib/x86_64- COPY --from=syslibs /usr/lib/x86_64-linux-gnu/libfribidi.so* /usr/lib/x86_64-linux-gnu/ # Set production defaults: port 4208 -ENV NODE_ENV=production \ +ENV RUNNING_IN_DOCKER=true \ + NODE_ENV=production \ HOST=0.0.0.0 \ PORT=4208 \ HTTPS_PORT=0 \ diff --git a/docs/api/routes-all.md b/docs/api/routes-all.md index 4003f82..1bb4111 100644 --- a/docs/api/routes-all.md +++ b/docs/api/routes-all.md @@ -235,7 +235,7 @@ _none_ - Returns: `200 { message: str }` #### Current user — `GET /auth/me` _none_ -- Returns: `200 { user: T32, googleClientId: str, schemaVersion: int }` +- Returns: `200 { user: T32, googleClientId: str, schemaVersion: int, vhost: bool, vhostSettings: str }` #### Set selected company — `PUT /auth/selected-company` - Params: `body: { companyId: int }` - Returns: `200 { user: T32 }` diff --git a/docs/api/routes/auth/me.md b/docs/api/routes/auth/me.md index d656307..dc60edc 100644 --- a/docs/api/routes/auth/me.md +++ b/docs/api/routes/auth/me.md @@ -22,7 +22,9 @@ Authenticated "picture": "…" }, "googleClientId": "…", - "schemaVersion": 1 + "schemaVersion": 1, + "vhost": true, + "vhostSettings": "…" } ``` diff --git a/docs/dash.sh b/docs/dash.sh index 170352b..f51619b 100755 --- a/docs/dash.sh +++ b/docs/dash.sh @@ -27,6 +27,7 @@ docker run -d \ -e GOOGLE_CLIENT_ID=928121624463-m9du45ek2d5f6p9cke8qpnf89ii9no20.apps.googleusercontent.com \ -e JWT_SECRET=dfhjkswezui32476sdjkhvbn347865 \ -e IMPLICIT_CREATE=true \ + -e VHOST_SETTINGS="" \ -e DB_PROVIDER=mssql \ -e MSSQL_DATABASE=dashback \ -e MSSQL_USER=sa \ diff --git a/src/api/auth/meJson.js b/src/api/auth/meJson.js index d50279d..fe5287c 100644 --- a/src/api/auth/meJson.js +++ b/src/api/auth/meJson.js @@ -12,5 +12,7 @@ export async function respondWithAuthenticatedUser(res, status, body) { ...body, googleClientId: env.googleClientId, schemaVersion, + vhost: env.vhost, + vhostSettings: env.vhostSettings, }); } diff --git a/src/api/routes/auth/me.js b/src/api/routes/auth/me.js index f050380..0997388 100644 --- a/src/api/routes/auth/me.js +++ b/src/api/routes/auth/me.js @@ -36,6 +36,12 @@ export function register(app, basePath = '') { * schemaVersion: * type: integer * description: Current database schema version + * vhost: + * type: boolean + * description: True when running in Docker (client may change feature set) + * vhostSettings: + * type: string + * description: Pipelined settings string from VHOST_SETTINGS env * 401: * description: Unauthorized — still includes `googleClientId` and `schemaVersion` for the frontend * content: @@ -50,6 +56,12 @@ export function register(app, basePath = '') { * schemaVersion: * type: integer * description: Current database schema version + * vhost: + * type: boolean + * description: True when running in Docker (client may change feature set) + * vhostSettings: + * type: string + * description: Pipelined settings string from VHOST_SETTINGS env */ app.get(`${basePath}/auth/me`, async (req, res) => { try { diff --git a/src/config/env.js b/src/config/env.js index 9f2ac28..5b1c695 100644 --- a/src/config/env.js +++ b/src/config/env.js @@ -12,7 +12,12 @@ function parseHttpsPort(val) { return Number.isInteger(n) && n > 0 ? n : 8443; } +const isDocker = process.env.RUNNING_IN_DOCKER === 'true'; + export default { + isDocker, + vhost: isDocker, + vhostSettings: process.env.VHOST_SETTINGS || '', host: process.env.HOST || '127.0.0.1', port: Number(process.env.PORT) || 4208, httpsPort: parseHttpsPort(process.env.HTTPS_PORT), @@ -50,7 +55,7 @@ export default { storageDir: process.env.STORAGE_DIR || resolve(__dirname, '../../data/storage'), }, backup: { - enabled: process.env.BACKUP_ENABLED !== 'false', + enabled: !isDocker && process.env.BACKUP_ENABLED !== 'false', dir: process.env.BACKUP_DIR ? resolve(process.env.BACKUP_DIR) : resolve(__dirname, '../../data/backups'), intervalMs: Number(process.env.BACKUP_INTERVAL_MS) || 60 * 60 * 1000, hourlyRetentionCount: Number(process.env.BACKUP_HOURLY_RETENTION) || 50, @@ -65,7 +70,7 @@ export default { key: process.env.REDIS_KEY || process.env.REDIS_HEALTH_KEY || 'healthcheck:latency_ms', }, healthMonitor: { - enabled: process.env.HEALTH_MONITOR_ENABLED !== 'false', + enabled: !isDocker && process.env.HEALTH_MONITOR_ENABLED !== 'false', intervalMs: Number(process.env.HEALTH_MONITOR_INTERVAL_MS) || 60_000, }, };