https://pptr.dev/troubleshooting#running-puppeteer-on-gitlabci
1.内容中,缺少libgbm-dev,补充上
FROM node:18.9.0-slim
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
#echo "" >>/etc/apt/sources.list
sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
WORKDIR /opt/app
ADD app/package.json /tmp/package.json
RUN apt-get update && apt-get install -yq libgbm-dev gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget
RUN cd /tmp && npm install && mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/ && npx @puppeteer/browsers install chrome@117 --platform linux --path /opt/.local-chromium
ADD . /opt/app/
CMD ["node", "index.js"]
2.和安装执行的系统版本有关,在debian9.5情况下,会出现依赖文件无法安装,大概如下:
dockerfile 安装gconf-service时出现 errors were encountered while processing:
gconf2-common
gconf-service
libgconf-2-4:amd64
E:sub-process /usr/bin.dpkg returned an error code
creating config file /etc/gconf/2/path with new version
stat:connot statx 'usr/share/gconf/default.path':operation noet permitted
dpkg:error processing package gconf2-common(--configure):
installed gconf2=common package post-installation script subprocess returned error exit status 1
dockerfile 安装gconf-server 时出现:
dpkg:dependency problem prevent configuration of libconf-2-4:amd64:
libgconf-2-:amd64 depends on gconf2-common(=3.2.6-7);however:
package gconf2-common is not c onfigured yet.
dpkg:error processing package libgconf-2-4:amd64(--configure):
dependency problems - leaving unconfigured
errors were encountered while processing:
gconf2-common
gconf-service
libgconf-2-4:amd64
E:sub-process /usr/bin.dpkg returned an error code
debconf:delaying package configuration,since apt-utils is not installed
但系统升级为debian10以上后,正常安装。