【问题标题】:How can we install google-chrome-stable on node 12(alpine )image using dockerfile?我们如何使用 dockerfile 在节点 12(alpine)图像上安装 google-chrome-stable?
【发布时间】:2020-05-25 10:20:19
【问题描述】:

Node 8 下面是对应的 Docker 文件

FROM node:8-slim
RUN apt-get update && apt-get install -yq libgconf-2-4
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update && apt-get install -y wget --no-install-recommends \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic ttf-freefont git \
      --no-install-recommends \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get purge --auto-remove -y curl \
    && rm -rf /src/*.deb
RUN wget -q -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \
    chmod +x /usr/local/bin/dumb-init
RUN mkdir app && useradd -m app && chown app app
USER app
WORKDIR app
COPY package.json .
RUN npm install --registry xxxxx --production
ENV CHROME_BIN=/usr/bin/chromium-browser \
    CHROME_PATH=/usr/lib/chromium/
COPY test test
COPY src src
# COPY config config
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD ["npm", "test"]

但同样不适用于 Node-12,是否需要对 Node 12 进行任何更改,它使用 alpine 版本,而 node-8 使用 ubuntu

【问题讨论】:

  • 你能发布完整的 Dockerfile 吗?
  • 更新了@nischay goyal
  • 为什么不能使用node-12 ubuntu?使用 alpine image 有什么限制吗?
  • 是的,我们只使用 node-12:alpine
  • 当您说“它不起作用”时,您遇到的具体问题是什么?您不能在基于 Alpine 的映像上运行 apt-get(它只是一个不同的包管理器),@nischaygoyal 使用基于 Ubuntu 的映像的建议将解决这个问题。

标签: javascript node.js docker dockerfile


【解决方案1】:

请使用此已构建的图像,其中包含节点 v12.16.2 和 chrome。

图片名称zenika/alpine-chrome:80-with-node

docker run -it zenika/alpine-chrome:80-with-node /bin/sh
/usr/src/app $ node -v
v12.16.2
/usr/src/app $ cat /etc/issue
Welcome to Alpine Linux 3.11
Kernel \r on an \m (\l)

参考:-https://github.com/Zenika/alpine-chrome

【讨论】:

  • 这不是问题,他明确问你如何安装 chrome 而不是它预先打包了哪些图像。
猜你喜欢
  • 2020-02-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-23
  • 2019-04-12
  • 2021-06-16
  • 2022-06-30
相关资源
最近更新 更多