build: write commit tag to json file inside docker image

pull/519/head
sct 4 years ago
parent 343f466788
commit 55f9e41f1b

@ -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

@ -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,
});
});

Loading…
Cancel
Save