From 1a9a20f5d9866464034a831121913f87a17269d5 Mon Sep 17 00:00:00 2001 From: Aravind Date: Tue, 14 Jul 2026 10:52:06 +0530 Subject: [PATCH] fix: install linux-musl sharp binaries in Docker (fixes 502 on Alpine) The standalone build runs on macOS and bundles darwin-arm64 native sharp binaries. These crash immediately on the Alpine Linux container, causing the Node process to exit and Dokploy's reverse proxy to return a 502 Bad Gateway. This adds a RUN step to remove the macOS binaries and install the correct @img/sharp-linuxmusl-x64 package at build time. --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7eeb2ac..055a4ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,15 @@ ENV HOSTNAME=0.0.0.0 # Copy the standalone build artifact (server.js, .next/, public/) COPY build /app +# The standalone build was created on macOS (darwin-arm64), so it bundles +# macOS-only native binaries for sharp (image optimisation). These crash +# on Linux/Alpine. Replace them with the correct musl-linux-x64 binaries. +RUN rm -rf node_modules/@img/sharp-darwin-arm64 \ + node_modules/@img/sharp-libvips-darwin-arm64 && \ + npm install --no-save --platform=linuxmusl --arch=x64 \ + @img/sharp-linuxmusl-x64@0.34.5 && \ + rm -rf /tmp/* /root/.npm + EXPOSE 3000 CMD ["node", "server.js"]