继续我的 docker。
之前遇到一个报错:
Error: Failed to launch the browser process! undefined
  [579:579:0430/015358.567760:ERROR:zygote_host_impl_linux.cc(105)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
 
 
 
 
  TROUBLESHOOTING: https://pptr.dev/troubleshooting
 
 
   ❯ ChildProcess.onClose node_modules/@puppeteer/browsers/src/launch.ts:507:11
 
 
  ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
 
 
 
 
   Test Files  1 failed (1)
        Tests  2 skipped (2)
     Start at  01:53:46
     Duration  12.37s (transform 815ms, setup 0ms, collect 3.88s, tests 4.55s, environment 2ms, prepare 573ms)
 
 
  npm notice
  npm notice New major version of npm available! 10.8.2 -> 11.3.0
  npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
  npm notice To update run: npm install -g npm@11.3.0
  npm notice
 
  | 
 
Gemini 说是因为浏览器的问题。
正常我们在一个 docker image 里,我们都是 root,但是这个 Chromium 不允许我们以 root 的身份去运行。
然后他给出来了两个解决办法,一个就是改 vitest 的配置,我首先选择是改这个 vitest 的配置,但是改完之后还是报错,要继续改,好像是因为新版的 vitest 要用新的写法之类的,要改的太多了,我就直接去用另外一个方法了。
另外一个方法就是,更改用户的身份,不是 root 就行了。这个就是改了改 dockerfile。
用的命令是
docker build --platform=linux/amd64 -t my-test-env:dev .
 
  | 
 
和
docker run -it --rm --platform=linux/amd64 -v "$(pwd):/app" -v /app/node_modules my-test-env:dev bash
 
  | 
 
还是报错
我就试了一下直接下载
npx puppeteer browsers install chrome
 
  | 
 
继续报错
询问 Gemini,告诉我还是要改 vitest 配置文件,兜兜转转又回去了,离谱。
这次改完之后可以运行了,但是遇到了下一个报错,timeout。
专门去搜了下文档,改了一下默认时间。
但是继续 timeout。
那这感觉就有很多可能性了。