gcloud auth在dockerfile中不起作用

问题描述 投票:1回答:1

我制作了一个多阶段的dockerfile,安装了我的npm包,然后尝试将它们部署到gcp

问题是,当我运行部署时,它告诉我它无法打开配置文件,并且我没有选择活动帐户

WARNING: Could not open the configuration file: [/root/.config/gcloud/configurations/config_default].
ERROR: (gcloud.functions.deploy) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

这是我的dockerfile:

FROM node:10.19.0-alpine3.9 AS build

ADD . /app
WORKDIR /app

RUN npm install

FROM google/cloud-sdk

WORKDIR /app
COPY --from=build /app /app

RUN gcloud auth activate-service-account --key-file /app/firebase-service-account.json
RUN gcloud config set project MY_PROJECT
RUN gcloud config set account [email protected]

我还写了一个bash脚本来构建和部署我的云功能

#! /bin/sh

docker build . -f deploy-functions.dockerfile -t cloud-functions-deploy

docker run cloud-functions-deploy gcloud functions deploy event-log-trigger \
--project ${GCP_PROJECT_ID} \
--entry-point eventLogBuilder \
--trigger-event providers/cloud.firestore/eventTypes/document.update \
--trigger-resource projects/${GCP_PROJECT_ID}/databases/\(default\)/documents/events/\{eventId\} \
--region=${GCP_REGION} --stage-bucket=${STAGE_BUCKET} --runtime nodejs10

[在我的第一个bash脚本中,我没有--project标志,但是需要添加它,以防它表示命令没有项目。似乎警告是正确的,即使我以root身份运行所有内容,它也无法打开config_default文件。

node.js google-cloud-platform google-cloud-functions dockerfile
1个回答
0
投票

您可以通过创建entrypoint.sh文件来克服此问题

© www.soinside.com 2019 - 2024. All rights reserved.