0

我必须使用 GC Cloud Build 配置 GC AppEngine 应用程序的自定义构建过程。
首先 - 我在 GC ComputeEngine 实例上有一个内部 python 存储库。它只能通过内部网络访问,我使用Remote-builderpip install在内部 GC 实例上运行命令。
从内部存储库下载依赖项后,我必须将结果部署到 GC AppEngine。

Cloudbuild.yaml
steps: /#Download dependencies from the internal repository - name: gcr.io/${ProjectName}/remote-builder env: - COMMAND=sudo bash workspace/download-dependencies.bash - ZONE=us-east1-b - INSTANCE_NAME=remote-cloud-build - INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7 - name: gcr.io/cloud-builders/docker args: ['build', '-t', 'gcr.io/${ProjectName}/app', '.'] - name: gcr.io/cloud-builders/docker args: ['push', 'gcr.io/${ProjectName}/app'] - name: gcr.io/cloud-builders/gcloud args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/${ProjectName}/${ProjectName}'] images: ['gcr.io/${ProjectName}/${ProjectName}']

应用程序.yaml:
runtime: python env: flex entrypoint: python main.py service: service-name runtime_config: python_version: 3

Dockerfile:
FROM gcr.io/google-appengine/python WORKDIR /app COPY . /app

下载-dependencies.bash:
#!/usr/bin/env bash easy_install pip pip install --upgrade pip pip install --upgrade setuptools pip install -r workspace/requirements.txt'

应用程序的新版本运行后gcloud builds submit --config cloudbuild.yaml 部署在 AppEngine 上,但它不起作用

也许问题是错误的图像?据我了解,我需要配置 Dockefile 以将所有自定义 python 依赖项收集到图像中。
你能帮我解决一下
吗提前谢谢!

更新 我根据谷歌指南更改了我的 Dockerfile:
FROM gcr.io/google-appengine/python RUN virtualenv /env ENV VIRTUAL_ENV /env ENV PATH /env/bin:$PATH ADD . /app CMD main.py
新错误是:/bin/sh: 1: main.py: not found
如果我将最后一行更改为:CMD app/main.py- 它创建版本并且不起作用

4

1 回答 1

2

最后,我完成了。有一些问题,我将在下面分享正确的配置。希望它会帮助某人。

steps:
# Move our code to instance inside the project to have access to the private repo
- name: gcr.io/${PROJECT_NAME}/remote-builder
  env:
  - COMMAND=sudo bash workspace/download-dependencies.bash:
  - ZONE=us-east1-b
  - INSTANCE_NAME=remote-cloud-build
  - INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7
#Build image with downloaded deps
- name: gcr.io/cloud-builders/docker
  args: ['build', '-t', 'gcr.io/${PROJECT_NAME}/${APP_NAME}', '.']
#Push image to project repo
- name: gcr.io/cloud-builders/docker
  args: ['push', 'gcr.io/${PROJECT_NAME}/${APP_NAME}']
#Deploy image to AppEngine
- name: gcr.io/cloud-builders/gcloud
  args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/${PROJECT_NAME}/${APP_NAME}']
images: ['gcr.io/${PROJECT_NAME}/${APP_NAME}']
timeout: '1800s'

下载-dependencies.bash:

#!/usr/bin/env bash
easy_install pip

pip install --upgrade pip
pip install --upgrade setuptools
pip install wheel
#Download private deps and save it to volume (share folder between steps)
pip wheel --no-deps -r workspace/private-dependencies.txt -w workspace/lib --no-binary :all:

Dockerfile:

FROM gcr.io/google-appengine/python
COPY . /${APP_NAME}
RUN virtualenv /env


ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

RUN pip install -r /${APP_NAME}/workspace/public-dependencies.txt
#Install private deps from volume
RUN pip install -f /${APP_NAME}/workspace/lib --no-index ${LIBRARY_NAME}

CMD gunicorn -b :$PORT main:app
于 2018-11-09T15:18:13.200 回答