Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker example does not work #68762

Open
1 task done
tommyvct opened this issue Aug 10, 2024 · 0 comments
Open
1 task done

Docker example does not work #68762

tommyvct opened this issue Aug 10, 2024 · 0 comments
Labels
examples Issue/PR related to examples

Comments

@tommyvct
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  4 06:37:13 UTC 2024 (ba01e0e)
  Available memory (MB): 32023
  Available CPU cores: 16
Binaries:
  Node: 22.3.0
  npm: 10.8.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-canary.111 // Latest available version is detected (15.0.0-canary.111).
  eslint-config-next: 14.2.5
  react: 19.0.0-rc-187dd6a7-20240806
  react-dom: 19.0.0-rc-187dd6a7-20240806
  typescript: 5.5.4
Next.js Config:
  output: N/A

Which example does this report relate to?

with-docker

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Docker

Describe the Bug

NextJS claimed:

Next.js can be deployed to any hosting provider that supports Docker containers.

I followed the guide at https://github.com/vercel/next.js/tree/canary/examples/with-docker, basically copy the dockerfile , change the output mode to standalone then run it. Unfortunately, I was presented with these unfortunate cryptic errors which they appear randomly:

I ran docker builder prune everytime before I run the dockerfile.

On node:18-alpine, the error is consistent:

 => [deps 3/4] COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./                              0.6sm
 => ERROR [deps 4/4] RUN     if [ -f yarn.lock ]; then yarn --frozen-lockfile;     elif [ -f package-lock.js  71.3s
------                                                                                                              
 > [deps 4/4] RUN     if [ -f yarn.lock ]; then yarn --frozen-lockfile;     elif [ -f package-lock.json ]; then npm ci;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;     else echo "Lockfile not found." && exit 1;     fi:
71.15 npm error Exit handler never called!
71.15 npm error This is an error with npm itself. Please report this error at:
71.15 npm error     <https://github.com/npm/cli/issues>
71.15 
71.16 
71.16 npm error A complete log of this run can be found in: /root/.npm/_logs/2024-08-10T15_40_06_106Z-debug-0.log
------
Dockerfile:11
--------------------
  10 |     COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
  11 | >>> RUN \
  12 | >>>     if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
  13 | >>>     elif [ -f package-lock.json ]; then npm ci; \
  14 | >>>     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
  15 | >>>     else echo "Lockfile not found." && exit 1; \
  16 | >>>     fi
  17 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c if [ -f yarn.lock ]; then yarn --frozen-lockfile;     elif [ -f package-lock.json ]; then npm ci;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;     else echo \"Lockfile not found.\" && exit 1;     fi" did not complete successfully: exit code: 1

Sometimes, it will complain sh: next: not found.

If I use node:20-alpine, the error will be somehow different:

 => ERROR [builder 4/4] RUN     if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.j  4.4s 
------                                                                                                       
 > [builder 4/4] RUN     if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.json ]; then npm run build;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build;     else echo "Lockfile not found." && exit 1;     fi:                                                                          
0.411                                                                                                        
0.411 > fucknextjs@0.1.0 build                                                                               
0.411 > next build
0.411 
0.831 Attention: Next.js now collects completely anonymous telemetry regarding usage.
0.832 This information is used to shape Next.js' roadmap and prioritize features.
0.832 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
0.832 https://nextjs.org/telemetry
0.832 
0.875   ▲ Next.js 15.0.0-canary.111
0.875 
0.876    Linting and checking validity of types ...
2.223    Creating an optimized production build ...
3.164 request to https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap failed, reason: connect ECONNREFUSED 127.0.0.1:7890
3.164 
3.164 Retrying 1/3...
3.265 request to https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap failed, reason: connect ECONNREFUSED 127.0.0.1:7890
3.265 
3.265 Retrying 2/3...
3.467 request to https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap failed, reason: connect ECONNREFUSED 127.0.0.1:7890
3.467 
3.467 Retrying 3/3...
3.870 FetchError: request to https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap failed, reason: connect ECONNREFUSED 127.0.0.1:7890
3.870     at ClientRequest.<anonymous> (/app/node_modules/next/dist/compiled/node-fetch/index.js:1:66159)
3.870     at ClientRequest.emit (node:events:519:28)
3.870     at onerror (/app/node_modules/next/dist/compiled/https-proxy-agent/index.js:1:1890)
3.870     at callbackError (/app/node_modules/next/dist/compiled/https-proxy-agent/index.js:1:2140)
3.870     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
3.870   type: 'system',
3.870   errno: 'ECONNREFUSED',
3.870   code: 'ECONNREFUSED'
3.870 }
4.269 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-win32-x64-msvc isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.269 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-win32-ia32-msvc isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.269 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-win32-arm64-msvc isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.269 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-linux-arm64-gnu isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.269 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-linux-arm64-musl isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.270 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-darwin-x64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.270 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@next/swc-darwin-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.271 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-win32-x64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.271 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-wasm32 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.272 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-win32-ia32 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.272 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-linuxmusl-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.272 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-linux-s390x isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.272 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-linux-arm isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.272 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-linux-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.273 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-linuxmusl-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.273 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-linux-s390x isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.273 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-linux-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.273 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-linux-arm isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.274 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-darwin-x64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.274 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-libvips-darwin-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.274 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-darwin-x64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.274 <w> [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Managed item /app/node_modules/@img/sharp-darwin-arm64 isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)
4.332 Failed to compile.
4.332 
4.332 pages/index.tsx
4.332 `next/font` error:
4.332 Failed to fetch `Inter` from Google Fonts.
4.332 
4.342 
4.342 > Build failed because of webpack errors
------
Dockerfile:30
--------------------
  29 |     
  30 | >>> RUN \
  31 | >>>     if [ -f yarn.lock ]; then yarn run build; \
  32 | >>>     elif [ -f package-lock.json ]; then npm run build; \
  33 | >>>     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
  34 | >>>     else echo "Lockfile not found." && exit 1; \
  35 | >>>     fi
  36 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.json ]; then npm run build;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build;     else echo \"Lockfile not found.\" && exit 1;     fi" did not complete successfully: exit code: 1

The error could also be:

 => [builder 3/4] COPY . .                                                                              0.0s 
 => ERROR [builder 4/4] RUN     if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.j  0.5s 
------                                                                                                       
 > [builder 4/4] RUN     if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.json ]; then npm run build;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build;     else echo "Lockfile not found." && exit 1;     fi:
0.424 
0.424 > qweb@0.1.0 build
0.424 > next build
0.424 
0.426 sh: next: not found
------
Dockerfile:30
--------------------
  29 |     
  30 | >>> RUN \
  31 | >>>     if [ -f yarn.lock ]; then yarn run build; \
  32 | >>>     elif [ -f package-lock.json ]; then npm run build; \
  33 | >>>     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
  34 | >>>     else echo "Lockfile not found." && exit 1; \
  35 | >>>     fi
  36 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c if [ -f yarn.lock ]; then yarn run build;     elif [ -f package-lock.json ]; then npm run build;     elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build;     else echo \"Lockfile not found.\" && exit 1;     fi" did not complete successfully: exit code: 127

P.S. I never thought webdev could be this tramatizing.

Expected Behavior

A docker container is successfully built and ran.

To Reproduce

npx create-next-app fucknextjs .

Follow the instructions, create Dockerfile, set output to standalone.

@tommyvct tommyvct added the examples Issue/PR related to examples label Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Issue/PR related to examples
Projects
None yet
Development

No branches or pull requests

1 participant