diff --git a/Dockerfile b/Dockerfile index a554e0024..8a0190bf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,8 @@ COPY --from=BUILD_IMAGE /app/dist ./dist COPY --from=BUILD_IMAGE /app/.next ./.next COPY --from=BUILD_IMAGE /app/node_modules ./node_modules +RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json + CMD yarn start EXPOSE 5055 diff --git a/server/routes/index.ts b/server/routes/index.ts index d03ddb696..cd8c23a6b 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,4 +1,5 @@ import { Router } from 'express'; +import path from 'path'; import user from './user'; import authRoutes from './auth'; import { checkUser, isAuthenticated } from '../middleware/auth'; @@ -14,6 +15,17 @@ import mediaRoutes from './media'; import personRoutes from './person'; import collectionRoutes from './collection'; import { getAppVersion } from '../utils/appVersion'; +import { existsSync } from 'fs'; +import logger from '../logger'; + +const COMMIT_TAG_PATH = path.join(__dirname, '../../committag.json'); +let commitTag = 'local'; + +if (existsSync(COMMIT_TAG_PATH)) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + commitTag = require(COMMIT_TAG_PATH).commitTag; + logger.info(`Commit Tag: ${commitTag}`); +} const router = Router(); @@ -22,7 +34,7 @@ router.use(checkUser); router.get('/status', (req, res) => { return res.status(200).json({ version: getAppVersion(), - commitTag: process.env.COMMIT_TAG || 'local', + commitTag, }); });