#Next.js Docker build fails (works locally) – Alpine + next.config.ts

1 messages · Page 1 of 1 (latest)

whole fox
#

I’m seeing a Docker-only build failure with Next.js:
Setup
Next.js 16 (with next.config.ts)
Node 20
Docker multi-stage build
ECS (Linux)
Base image: node:20-alpine
Behavior
✅ next build works locally
❌ Fails during Docker build with:
Failed to load next.config.ts
Error: No prebuild or local build of @parcel/watcher found
Tried @parcel/watcher-linux-x64-musl
Notes
Happens only inside Docker
I already tried libc6-compat
Looks like a musl vs glibc / native dependency issue
Error surfaces while loading next.config.ts
Questions
Is Alpine unsupported / risky for Next.js builds due to native deps?
Is switching to node:*-slim the recommended fix for ECS?
Any known best practices here?
Appreciate any insights 🙏

"dependencies": {
"@headlessui/react": "^2.2.9",
"@reduxjs/toolkit": "^2.11.0",
"axios": "^1.13.2",
"embla-carousel-auto-scroll": "^8.6.0",
"embla-carousel-autoplay": "^8.6.0",
"embla-carousel-react": "^8.6.0",
"newrelic": "^13.8.1",
"next": "^16.0.1",
"next-auth": "^4.24.11",
"next-intl": "^4.0.0",
"react": "^19.2.0",
"react-dom": "^19.2.1",
"react-loading-skeleton": "^3.5.0",
"react-redux": "^9.2.0",
"react-toastify": "^11.0.5",
"tailwindcss-rtl": "^0.9.0"
},
"devDependencies": {
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@eslint/eslintrc": "^3.1.0",
"@playwright/test": "^1.51.1",
"@tailwindcss/postcss": "^4",
"@types/lodash": "^4.17.5",
"@types/node": "^20.14.5",
"@types/react": "^19.2.0",
"@types/react-dom": "^19.2.3",
"@types/newrelic": "^9.14.8",
"commitlint": "^20.1.0",
"eslint": "^9.38.0",
"eslint-config-next": "^16.0.1",
"husky": "^9.1.7",
"lint-staged": "^16.2.6",
"prettier": "^3.6.2",
"tailwindcss": "^4",
"typescript": "^5.9.3"
},

brisk schoonerBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

burnt egret
# whole fox I’m seeing a Docker-only build failure with Next.js: Setup Next.js 16 (with next...

Alpine + native Node dependencies = pain. The @parcel/watcher issue is because Alpine uses musl libc, not glibc, and the prebuilt binaries don't exist for musl.

Two fixes:

Option 1: Switch to slim (recommended)

FROM node:20-slim

Uses glibc, prebuilt binaries work out of the box. This is the safer choice for Next.js builds with native deps.

Option 2: Stay on Alpine but install build tools

FROM node:20-alpine
RUN apk add --no-cache python3 make g++ libc6-compat

This lets npm compile native deps from source, but adds build time and image size.

My recommendation: Just use node:20-slim for your build stage. Alpine is great for tiny images but not worth the native dependency headaches with Next.js. The size difference is minimal compared to the debugging pain.

Your ECS deployment will thank you.