首页 > 解决方案 > Docker - Puppeteer 需要一些东西并且不会运行

问题描述

我已经从 NodeJS 应用程序创建了一个带有 Docker 的容器,
但是当我尝试运行它时,应用程序将启动但进入错误循环。

我的 Dockerfile 包含

RUN npm install

但它不断突破:

ERROR PuppeteerCrawler:PuppeteerPool: Browser launch failed {"id":12}
  Error: Could not find browser revision 756035. Run "npm install" or "yarn install" to download a browser binary

如果我运行 Node main.js 没有问题。

//Dockerfile 
FROM apify/actor-node-basic
    
COPY package*.json ./

RUN npm --quiet set progress=false \  && npm install --only=prod
--no-optional \  && echo "Installed NPM packages:" \  && npm list \  && echo "Node.js version:" \  && node --version \  && echo "NPM version:" \  && npm --version

COPY . ./

WORKDIR . 
USER node 

RUN npm install 
COPY --chown=node:node . . 
EXPOSE 8080 
CMD [ "node", "Worker.js" ]

// package.json
    {
        "name": "SoccerBrain",
        "version": "0.0.1",
        "description": "This is an example of an Apify actor.",
        "dependencies": {
            "apify": "^0.21.0",
            "puppeteer": "^5.0.0",
            "rimraf": "^3.0.2"
        },
        "devDependencies": {},
        "scripts": {
            "start": "node Worker.js",
            "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
        },
        "author": "It's not you it's me",
        "license": "ISC"
    }

什么是附加?

标签: node.jsdockerpuppeteer

解决方案


推荐阅读