Release: weekly deploy
This commit is contained in:
+2
-12
@@ -12,16 +12,13 @@ const { requireCurator } = require('./middleware/auth');
|
||||
const { logCuratorAction } = require('./audit-log');
|
||||
const authRoutes = require('./routes/auth');
|
||||
const { ensurePaintingImages, preloadArtistImagesLocal, replacePaintingImageFromUrl, replaceArtistPortraitFromUrl, clearPaintingImage, deletePainting, clearArtistPortrait, replacePaintingImageFromBuffer, replaceArtistPortraitFromBuffer, IMAGE_DIR } = require('./image-service');
|
||||
const { getVersionInfo } = require('./version-info');
|
||||
const { searchGoogleImagesFirst, searchArtistPortraitFirst, searchPaintingImagesMany, searchArtistPortraitMany, fetchImageBuffer, friendlyImageFetchError, pickExt } = require('../scripts/image-fetcher');
|
||||
|
||||
const app = express();
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
const PORT = Number(process.env.PORT) || 3001;
|
||||
const PUBLIC_URL = process.env.PUBLIC_URL || '';
|
||||
const APP_ENV = process.env.APP_ENV || (process.env.DB_NAME === 'gallery_prod' ? 'prod' : 'dev');
|
||||
const IMAGE_TAG = process.env.IMAGE_TAG || 'local';
|
||||
const GIT_SHA = process.env.GIT_SHA || '';
|
||||
const APP_VERSION = process.env.npm_package_version || '0.0.0';
|
||||
|
||||
if (process.env.TRUST_PROXY === '1' || process.env.TRUST_PROXY === 'true') {
|
||||
app.set('trust proxy', 1);
|
||||
@@ -1044,14 +1041,7 @@ app.get('/api/bounds', async (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/version', async (_req, res) => {
|
||||
res.json({
|
||||
app_env: APP_ENV,
|
||||
app_version: APP_VERSION,
|
||||
image_tag: IMAGE_TAG,
|
||||
git_sha: GIT_SHA,
|
||||
db_name: process.env.DB_NAME || '',
|
||||
public_url: PUBLIC_URL || '',
|
||||
});
|
||||
res.json(getVersionInfo());
|
||||
});
|
||||
|
||||
const CLIENT_DIST = path.join(__dirname, '..', 'client', 'dist');
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const rootDir = path.join(__dirname, '..');
|
||||
|
||||
function readPackageVersion() {
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8'));
|
||||
return pkg.version || '0.0.0';
|
||||
} catch {
|
||||
return '0.0.0';
|
||||
}
|
||||
}
|
||||
|
||||
function readGitSha() {
|
||||
if (process.env.GIT_SHA) {
|
||||
return process.env.GIT_SHA;
|
||||
}
|
||||
try {
|
||||
return execSync('git rev-parse --short HEAD', {
|
||||
cwd: rootDir,
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
}).trim();
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getVersionInfo() {
|
||||
const dbName = process.env.DB_NAME || '';
|
||||
const appEnv = process.env.APP_ENV || (dbName === 'gallery_prod' ? 'prod' : 'dev');
|
||||
const imageTag = process.env.IMAGE_TAG || (appEnv === 'prod' ? 'unknown' : 'dev-local');
|
||||
|
||||
return {
|
||||
app_env: appEnv,
|
||||
app_version: process.env.APP_VERSION || readPackageVersion(),
|
||||
image_tag: imageTag,
|
||||
git_sha: readGitSha(),
|
||||
built_at: process.env.BUILD_TIME || '',
|
||||
db_name: dbName,
|
||||
public_url: process.env.PUBLIC_URL || '',
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { getVersionInfo };
|
||||
Reference in New Issue
Block a user