Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(ci): replace static version import with dynamic version loader, update Dockerfile and add utility function
johaven15f4752906ac
diff --git a/Dockerfile b/Dockerfileindex af62f32f..37bf45bc 100644--- a/Dockerfile+++ b/Dockerfile@@ -13,6 +13,7 @@ RUN apk add --no-cache su-exec && \WORKDIR /appCOPY --from=build --chown=8888:8888 /build/LICENSE .COPY --from=build --chown=8888:8888 /build/dist/ .+COPY --from=build --chown=8888:8888 /build/package.json ./server/COPY --from=build --chown=8888:8888 /build/node_modules ./node_modulesCOPY --from=build --chown=8888:8888 /build/backend/migrations ./migrationsCOPY --from=build --chown=8888:8888 /build/environment/environment.dist.yaml ./environment/environment.dist.yamldiff --git a/backend/src/app.constants.ts b/backend/src/app.constants.tsindex 0a15978c..9821412b 100644--- a/backend/src/app.constants.ts+++ b/backend/src/app.constants.ts@@ -3,10 +3,11 @@* This file is part of Sync-in | The open source file sync and share solution* See the LICENSE file for licensing details*/-import { version } from '../../package.json'-export const VERSION = version-export const USER_AGENT = `sync-in-server/${version}`+import { loadVersion } from './app.functions'++export const VERSION = loadVersion()+export const USER_AGENT = `sync-in-server/${VERSION}`export const CONTENT_SECURITY_POLICY = (onlyOfficeServer: string) => ({useDefaults: false,directives: {diff --git a/backend/src/app.functions.ts b/backend/src/app.functions.tsnew file mode 100644index 00000000..bdfd1257--- /dev/null+++ b/backend/src/app.functions.ts@@ -0,0 +1,32 @@+/*+ * Copyright (C) 2012-2025 Johan Legrand <[email protected]>+ * This file is part of Sync-in | The open source file sync and share solution+ * See the LICENSE file for licensing details+ */++import { existsSync, readFileSync } from 'fs'+import { join, resolve } from 'node:path'+import { IS_TEST_ENV } from './configuration/config.constants'++export function loadVersion(): string {+ let version: string | undefined+ const currentDir = resolve(join(__dirname, IS_TEST_ENV ? '../../' : '.'))+ const packageJson = 'package.json'+ const candidatePaths = [join(currentDir, `./${packageJson}`), join(currentDir, `../${packageJson}`), join(currentDir, `../../${packageJson}`)]++ for (const p of candidatePaths) {+ if (!existsSync(p)) continue+ try {+ version = JSON.parse(readFileSync(p, 'utf8')).version+ break+ } catch (e) {+ console.error(`unable to load version from: ${p} - ${e}`)+ }+ }++ if (!version) {+ throw new Error('Application version not found (package.json not readable on known paths)')+ }++ return version+}