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.
27 lines
872 B
Docker
27 lines
872 B
Docker
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Next.js standalone runtime. Required because the contact form's Server
|
|
# Action (sendEmail.ts, SMTP via nodemailer) needs a live Node process -
|
|
# it cannot run under static/nginx serving.
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
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"]
|