使用 Cloud Build 从 Dockerfile 安装 ArtifactRegistry Python 包

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

我的 Artifact 注册表存储库中有一个 python 包。

我的 Dataflow Flex 模板使用以下命令打包在 Docker 映像中:

gcloud builds submit --tag $CONTAINER_IMAGE .

由于开发人员不断更改管道的源代码,因此通常从他们的计算机运行此命令来重建映像。

这是我的 Dockerfile:

FROM gcr.io/dataflow-templates-base/python311-template-launcher-base

ARG WORKDIR=/template
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}

ENV PYTHONPATH ${WORKDIR}
ENV FLEX_TEMPLATE_PYTHON_SETUP_FILE="${WORKDIR}/setup.py"
ENV FLEX_TEMPLATE_PYTHON_PY_FILE="${WORKDIR}/main.py"

RUN pip install --no-cache-dir -U pip && \
    pip install --no-cache-dir -U keyrings.google-artifactregistry-auth

RUN pip install --no-cache-dir -U --index-url=https://europe-west9-python.pkg.dev/sample-project/python-repo/ mypackage

COPY . ${WORKDIR}/
    
ENTRYPOINT ["/opt/google/dataflow/python_template_launcher"]

我收到以下错误:

ERROR: No matching distribution found for mypackage
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1

我猜 Cloud Build 进程没有访问权限。我对如何从 Dockerfile 获取它们有点困惑。

我发现一篇文章提到了使用 Docker 进程读取的服务帐户密钥文件,但我想避免这种情况。我可以使用服务帐户模拟功能吗?

python dockerfile google-cloud-dataflow google-cloud-build google-artifact-registry
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.