Skip to content

Commit c112ac4

Browse files
committed
Bugfix(modeling-commons): fix sharp/IPX native binary in frontend image
Consolidates the IPX hardening work: - Bypass IPX for SVG images. - Use Debian useradd/groupadd in the frontend image. - Pin sharp via root resolutions. - Reinstall sharp in the runtime image as a flat tree: Nitro symlinks the native packages to @version-suffixed dirs, breaking the $ORIGIN-relative rpath the sharp binding uses to load libvips (ERR_DLOPEN_FAILED).
1 parent d27804a commit c112ac4

4 files changed

Lines changed: 22 additions & 339 deletions

File tree

apps/modeling-commons-frontend/Dockerfile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,23 @@ ENV NUXT_PUBLIC_CDN_URL=${NUXT_PUBLIC_CDN_URL}
2323
ENV NUXT_PUBLIC_NETLOGO_WEB_URL=${NUXT_PUBLIC_NETLOGO_WEB_URL}
2424
ENV NUXT_PUBLIC_GA_TRACKING_ID=${NUXT_PUBLIC_GA_TRACKING_ID}
2525

26-
RUN addgroup -g 1001 -S nodejs && adduser -S nuxt -u 1001 -G nodejs
26+
RUN groupadd -r -g 1001 nodejs && useradd -r -u 1001 -g nodejs -s /usr/sbin/nologin nuxt
2727
WORKDIR /app
2828
COPY .output .output
29+
30+
# Nitro symlinks sharp's native packages to @version-suffixed dirs under
31+
# .output/.nitro, which breaks the $ORIGIN-relative rpath the sharp binding uses
32+
# to find libvips at load time (ERR_DLOPEN_FAILED: libvips-cpp.so). Reinstall
33+
# sharp (same traced version) as a flat tree so the rpath resolves.
34+
RUN SHARP_VERSION="$(node -p "require('./.output/server/node_modules/sharp/package.json').version")" \
35+
&& npm install --no-save --no-audit --no-fund \
36+
--os=linux --cpu="$(node -p process.arch)" --libc=glibc \
37+
--prefix /tmp/sharp "sharp@${SHARP_VERSION}" \
38+
&& rm -rf .output/server/node_modules/sharp .output/server/node_modules/@img \
39+
&& cp -R /tmp/sharp/node_modules/sharp .output/server/node_modules/sharp \
40+
&& cp -R /tmp/sharp/node_modules/@img .output/server/node_modules/@img \
41+
&& rm -rf /tmp/sharp
42+
2943
USER nuxt
3044
EXPOSE 3005
3145
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \

apps/modeling-commons-frontend/app/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232

3333
<NuxtLink to="https://www.netlogo.org/" target="_blank" rel="noopener noreferrer" class="mt-8 text-center lg:text-left text-md">
34-
Powered by <NuxtImg :src="NetlogoLogo" class="inline-block h-6 w-auto -mt-0.5 -ml-1" />
34+
Powered by <img :src="NetlogoLogo" alt="NetLogo" class="inline-block h-6 w-auto -mt-0.5 -ml-1" />
3535
</NuxtLink>
3636
</div>
3737
<MarqueeGallery class="lg:w-5xl" height="80dvh" column-gap="12px">

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"node-forge": ">=1.3.2",
9292
"@internationalized/date": "3.12.1",
9393
"@tailwindcss/postcss": "^4.3.0",
94-
"tailwind-merge": "^3.3.1"
94+
"tailwind-merge": "^3.3.1",
95+
"sharp": "0.34.5"
9596
}
9697
}

0 commit comments

Comments
 (0)