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"]