fix(images): ship Linux codecs and preserve original-image fallback
Vendor the locked sharp Linux runtime and verify it during Docker builds. Add complete image response lengths and persistent frontend fallbacks, with real-codec HTTP and isolated release regression tests. Refresh tested API, admin and customer release artifacts. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Copied beside app.js. No Nest bootstrap, environment files, database or network.
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { createRequire } = require('node:module');
|
||||
|
||||
async function main() {
|
||||
const root = __dirname;
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'image-runtime.json'), 'utf8'));
|
||||
assert.equal(process.platform, manifest.platform, 'Validate native images on the target Linux runtime');
|
||||
assert.equal(process.arch, manifest.arch, 'Image artifact targets Linux x64');
|
||||
const vendor = fs.realpathSync(path.join(root, 'vendor'));
|
||||
// Use absolute package paths so a developer's node_modules cannot mask an
|
||||
// incomplete artifact. Also check every dependency against the build manifest.
|
||||
for (const [name, version] of Object.entries(manifest.versions)) {
|
||||
const packagePath = path.join(vendor, name, 'package.json');
|
||||
const real = fs.realpathSync(packagePath);
|
||||
assert.ok(real.startsWith(vendor + path.sep), `Dependency escapes artifact: ${name}`);
|
||||
assert.equal(JSON.parse(fs.readFileSync(real, 'utf8')).version, version, name);
|
||||
}
|
||||
const sharp = createRequire(path.join(vendor, 'sharp', 'package.json'))(path.join(vendor, 'sharp'));
|
||||
assert.equal(sharp.versions.sharp, manifest.versions.sharp);
|
||||
const encoded = await sharp({ create: { width: 32, height: 24, channels: 3, background: '#557799' } }).webp().toBuffer();
|
||||
const decoded = await sharp(encoded).raw().toBuffer({ resolveWithObject: true });
|
||||
assert.equal(decoded.info.width, 32);
|
||||
assert.equal(decoded.info.height, 24);
|
||||
assert.equal((await sharp(encoded).metadata()).format, 'webp');
|
||||
console.log(`Image runtime OK: sharp ${sharp.versions.sharp}, libvips ${sharp.versions.vips}, ${encoded.length} byte WebP`);
|
||||
}
|
||||
|
||||
main().catch((err) => { console.error(err); process.exitCode = 1; });
|
||||
Reference in New Issue
Block a user