mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(docker): ship libvips so sharp can actually load at runtime (#6499)
* fix(docker): ship libvips so sharp can actually load at runtime * style(config): use TSDoc for the tracing-includes note
This commit is contained in:
@@ -6,15 +6,7 @@ import os from 'os'
|
||||
import path from 'path'
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
/**
|
||||
* `sharp` resolves a platform-specific `@img/sharp-*` native binary that the
|
||||
* standalone file tracer cannot follow, so a deployment can ship without it. It
|
||||
* must therefore be loaded lazily and its failure contained: an unreadable OG
|
||||
* dimension is optional metadata, not a reason to take down `/blog`, `/library`,
|
||||
* and every tag, author, slug, and RSS route that reads the registry.
|
||||
*
|
||||
* This mock makes `import('sharp')` fail the way a missing native binary does.
|
||||
*/
|
||||
/** Fails `import('sharp')` the way an unloadable native binary does. */
|
||||
vi.mock('sharp', () => {
|
||||
throw new Error('Could not load the sharp module using the linux-x64 runtime')
|
||||
})
|
||||
|
||||
@@ -103,12 +103,9 @@ export function createContentRegistry(config: ContentRegistryConfig): ContentReg
|
||||
* `image-size` package, archived upstream with unpatched DoS advisories in
|
||||
* its ICNS/JXL/HEIF parsers (GHSA-w3rx-r6r6-pgpr, GHSA-5p2g-fcmc-qvqq).
|
||||
*
|
||||
* `sharp` is loaded lazily, never as a top-level import. It resolves a
|
||||
* platform-specific `@img/sharp-*` native binary that the standalone file
|
||||
* tracer cannot follow, so a deployment that ships without it makes
|
||||
* `import 'sharp'` throw at module scope — which would take down every route
|
||||
* that touches this registry (`/blog`, `/library`, their tag, author, slug,
|
||||
* and RSS routes) rather than degrading one optional OG dimension.
|
||||
* Imported lazily, never at module scope: sharp resolves a native binary, and a
|
||||
* top-level import that fails to load would take down every route reading this
|
||||
* registry instead of dropping one optional dimension.
|
||||
*/
|
||||
async function readOgImageDimensions(
|
||||
ogImage: string
|
||||
|
||||
@@ -168,11 +168,11 @@ const nextConfig: NextConfig = {
|
||||
'/api/internal/file-doc/seed': ['./node_modules/jsdom/**/*'],
|
||||
'/api/internal/file-doc/merge': ['./node_modules/jsdom/**/*'],
|
||||
'/api/internal/file-doc/persist': ['./node_modules/jsdom/**/*'],
|
||||
'/*': [
|
||||
'./node_modules/sharp/**/*',
|
||||
'./node_modules/@img/**/*',
|
||||
'./lib/execution/sandbox/bundles/*.cjs',
|
||||
],
|
||||
/**
|
||||
* No `sharp`/`@img` entries: these globs resolve against apps/sim while both hoist to the
|
||||
* monorepo root, so they matched nothing. docker/app.Dockerfile copies them instead.
|
||||
*/
|
||||
'/*': ['./lib/execution/sandbox/bundles/*.cjs'],
|
||||
},
|
||||
experimental: {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user