"gcloud构建所提交的内容..."做? [英] What does "gcloud builds submit ... " do?

查看:53
本文介绍了"gcloud构建所提交的内容..."做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 gcloud构建提交的作用.就我而言,我正在运行 GCloud运行教程

I would like to know what gcloud builds submit does. In my case I am running the GCloud run tutorial.

官方文档指出,它提交了构建.这不是特别有用的信息.

The official documentation states that it submits a build. This is not a particularly helpful piece of information.

有人可以为此提供更多背景信息吗?

Can someone provide some more context to this?

什么是内部版本?一个图像?一个jar文件?该内部版本"要提交到哪里?

What is a build? An Image? A jar file? Where is this 'build' being submitted to?

提交"是什么意思?这个提交"过程是否会通过网络推送我的构建".

What does 'submitting' mean? Does this 'submit' process push my 'build' over the network.

当我运行 gcloud builds commit 时,它似乎也在创建docker映像.所以这也是创建构建,然后是提交吗?!

When I run gcloud builds submit it also seems to be creating a docker image. So this is also creating the build, and then it is submitting it ?!!??

推荐答案

Cloud Build是一项服务,该服务将一个或多个容器映像系列应用到一些初始输入文件集,并经常生成某些工件,通常(但不总是)生成其他工件容器映像,通常是一些最初提交的源代码,该服务将这些源代码构建到容器映像中.

Cloud Build is a service that applies one or more container images in series to some initial set of input files and often generating some artifacts, often (not always) another container image, often some source code that was initially submitted that the service builds into a container image.

Cloud Build在某种程度上类似于Linux管道,其中一些输入是通过一系列命令通过管道传输数据来转换的:克|h |... .另外,您可能会认为它是复合函数: h(g(f(x())).

Cloud Build is somewhat analogous to e.g. Linux pipelines where some input is transformed by piping data through a series of commands: f | g | h | .... Alternatively you may think of it as composited functions: h(g(f(x))).

Cloud Build被描述为(并命名为)用于构建(将代码编码到容器中)的服务,但是,正如您所知,实际上,这些步骤可能是任何容器映像,并且通常具有副作用,例如将容器映像部署到其他服务例如云运行.

Cloud Build is described (and named) as a service to build (code into containers) but, as you know, actually the steps may be any container image and often these have side-effects such as deploying container images to other services e.g. Cloud Run.

Cloud Build比Google宣传的通用得多.Google将其文档范围限制为基于云的服务来构建软件.

Cloud Build is much more general-purpose than Google advertises it. Google limits its scope in its documentation to a cloud-based service to build software.

运行 gcloud builds commit ... 时,您将提供一些源代码以及Dockerfile或配置文件.前者是第二种情况的简单情况,后者是一个配置文件,其中包含运行 docker build ... .

When you run gcloud builds submit... you provide some source code and either a Dockerfile or a configuration file. The former is a simple case of the second, a configuration file containing a single step that runs docker build....

配置文件(YAML)列出了一系列具有一系列参数的容器映像.最初,Cloud Build将指定的源(可以是当前目录)复制到Compute Engine VM(由服务创建),作为目录(自动安装到每个容器中)作为/workspace .

Configuration files (YAML) list a series of container images with parameters that are run in series. Initially Cloud Build copies a designated source (can be the current directory) to a Compute Engine VM (created by the service) as a directory (that's automatically mounted into each container) as /workspace.

容器(定义为配置文件中的步骤)可以在此文件系统上运行(例如,代码文件,验证文件以及您可以在容器中执行的任何操作).总而言之,配置文件通常会存储已在(例如)容器中创建的容器.容器注册表.

Containers (defined as steps in the configuration file) may operate on this file system (e.g. compline code, validate files, anything that you can do in a container). Often, in conclusion, config files store containers that have been created in e.g. Container Registry.

Cloud Build可能会使新手感到困惑.本着一种有趣的精神,并以一种展示Cloud Build用途广泛的方式,以下是用Cloud Build编写的Rube Goldberg机器,它可以解决二次方程式:

Cloud Build can be confusing to newcomers. In a spirit of fun and as a way to show that Cloud Build is quite general-purpose, here's a Rube Goldberg machine written in Cloud Build that solves quadratic equations:

对于以下 cloudbuild.yaml :

steps:
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "Quadratic: $(cat a)x²+$(cat b)x+$(cat c)s=0"'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "$(cat b) * $(cat b)" | bc -l > b2'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "4 * $(cat a) * $(cat c)" | bc -l > 4ac'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "$(cat b2) - $(cat 4ac)" | bc -l > b2-4ac'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "sqrt($(cat b2-4ac))" | bc -l > sqrt'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "-($(cat b)) + $(cat sqrt)" | bc -l > add'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "-($(cat b)) - $(cat sqrt)" | bc -l > sub'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "2 * $(cat a)" | bc -l > 2a'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "$(cat add)/$(cat 2a)" | bc -l > root1'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "$(cat sub)/$(cat 2a)" | bc -l > root2'
  - name: busybox
    args:
      - ash
      - -c
      - 'echo "Roots are: $(cat root1); $(cat root2)"'

它期望以 $ {PWD} 中的3个文件( a b c )包含值ax²+ bx + c = 0 的值.因此,对于8x²-10x+ 3 :

It expects 3 files (a, b, c) in ${PWD} containing the values of ax²+bx+c=0. So, for 8x²-10x+3:

echo "8" > a
echo "-10" > b
echo "3" > c

您可以通过以下方式运行它:

You can run it with:

gcloud builds submit ${PWD} \
--config=./cloudbuild.yaml \
--project=${PROJECT}

说明用于解决二次方程式的Rube Goldberg云构建机器

这篇关于"gcloud构建所提交的内容..."做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆