首页 > 解决方案 > 在 docker 中将 google cloud sdk 容器与 nodejs 应用程序相结合

问题描述

我是 docker 新手,我正在尝试使用本指南使用 dscc-gen 和 nodejs 构建 datastudio 可视化。 https://developers.google.com/datastudio/visualization/local-dev

运行我的 dockerfile 时,出现以下错误:

    Step 5/8 : RUN sh -c '/bin/echo' -e 'calendar-chart\ngs://datastudio-visualisations/calendar-chart-dev\ngs://datastudio-visualisations/calendar-chart-prod\n' | npx @google/dscc-gen viz
 ---> Running in 9316cb8dd84e
npx: installed 318 in 22.446s
ERROR: gsutil is not installed, but is needed for the viz template.
Install gsutil (https://cloud.google.com/storage/docs/gsutil_install), then re-run this command to continue.
No files have been created.

The command '/bin/sh -c sh -c '/bin/echo' -e 'calendar-chart\ngs://datastudio-visualisations/calendar-chart-dev\ngs://datastudio-visualisations/calendar-chart-prod\n' | npx @google/dscc-gen viz' returned a non-zero code: 1

gsutil 存在于 docker hub 中的 google cloud sdk 中。https://hub.docker.com/r/google/cloud-sdk

如何让 sdk 在我的 docker 文件中工作?因为据我所知,它并不是真正运行的服务器。只是云平台的“连接器”。

这是我在 de nodejs 应用程序中的 Dockerfile。

FROM node:current

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
RUN sh -c '/bin/echo' -e 'calendar-chart\ngs://url-dev\ngs://url-prod\n' | npx @google/dscc-gen viz

# Bundle app source
COPY . .

CMD [ "npm", "run", "start"]

EXPOSE 8080

我知道如果您正在运行服务器,您可以使用 docker compose。这可能是一个多阶段构建,但我被困在我需要在哪里引用的文件夹上。

标签: node.jsdockergoogle-cloud-sdk

解决方案


推荐阅读