attempt to fix version number display in prod
This commit is contained in:
@@ -12,4 +12,5 @@ COPY --from=builder /app/dist ./dist
|
|||||||
COPY --from=builder /app/node_modules ./node_modules
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
COPY --from=builder /app/prisma ./prisma
|
COPY --from=builder /app/prisma ./prisma
|
||||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
CMD ["node", "dist/src/main.js"]
|
CMD ["node", "dist/src/main.js"]
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
import { PrismaService } from './database/prisma.service';
|
import { PrismaService } from './database/prisma.service';
|
||||||
|
|
||||||
const appVersion =
|
const appVersion = (() => {
|
||||||
process.env.APP_VERSION ?? process.env.npm_package_version ?? 'unknown';
|
if (process.env.APP_VERSION) return process.env.APP_VERSION;
|
||||||
|
try {
|
||||||
|
const pkg = JSON.parse(
|
||||||
|
readFileSync(join(__dirname, '../../package.json'), 'utf-8'),
|
||||||
|
) as { version: string };
|
||||||
|
return pkg.version;
|
||||||
|
} catch {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
export type DatabaseHealth = 'OK' | 'DOWN';
|
export type DatabaseHealth = 'OK' | 'DOWN';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user