zoukankan      html  css  js  c++  java
  • Puppeteer在docker下踩坑记录

    最近有需求要进行浏览器截图,就开始研究Puppeteer。因为项目是k8s的所有还是遇到了一些坑来做记录。

    1.依赖

    基础镜像缺少Chromium所需要的依赖,所有导致运行报错。

    centos安装依赖

    yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
    

    alpine安装依赖

    # 设置阿里镜像源
    echo "https://mirrors.aliyun.com/alpine/edge/main" > /etc/apk/repositories
    echo "https://mirrors.aliyun.com/alpine/edge/community" >> /etc/apk/repositories
    echo "https://mirrors.aliyun.com/alpine/edge/testing" >> /etc/apk/repositories
    
    # 安装Chromium及依赖,包括中文字体支持
    apk -U --no-cache update
    apk -U --no-cache --allow-untrusted add zlib-dev xorg-server dbus ttf-freefont chromium wqy-zenhei@edge -f
    

      

    2.时区问题

    容器的时区一定要设置好,不然Chrome浏览器的时区也会跟着出问题。

    因为暂时不太清楚怎么在Puppeteer中对Chrome设置时区,所有只能先在dockerfile中加入如下内容:

    RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    RUN echo 'Asia/Shanghai' >/etc/timezone

    参考文章 https://www.jianshu.com/p/6a07fbd5b299

  • 相关阅读:
    洛谷P1628 合并序列
    洛谷 P1334 瑞瑞的木板==P2664 【题目待添加】
    洛谷P1090 合并果子
    洛谷P3378 【模板】堆
    codevs 3129 奶牛代理商IX
    codevs 3344 迷宫
    codevs 2549 自然数和分解
    codevs 3096 流输入练习——寻找Sb.VI
    洛谷 P1821 [USACO07FEB]银牛派对Silver Cow Party
    洛谷 P1629 邮递员送信
  • 原文地址:https://www.cnblogs.com/naocanzhishen/p/12221738.html
Copyright © 2011-2022 走看看