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.
This commit is contained in:
@@ -12,6 +12,15 @@ ENV HOSTNAME=0.0.0.0
|
|||||||
# Copy the standalone build artifact (server.js, .next/, public/)
|
# Copy the standalone build artifact (server.js, .next/, public/)
|
||||||
COPY build /app
|
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
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
Reference in New Issue
Block a user