Google Cloudbuild yaml file 中 entrypoint 和 args 的写法
编写cloudbuild.yaml 时有几个关键参数
entrypoint 和 args 的基本介绍
id: 显示在 cloud build logs 里的item 名字
name: docker 镜像名字 - 下面的命令会在这个镜像的1个容器instance 内执行
entrypoint: 执行的命令入口 , 只能有1个对象
args: 命名的参数, 它是1个list
问题来了, 如何理解深而慢是entrypoint 和 args
entrypoint 就是执行的命令 bin file 名字, args 是参数, 不能混淆
例如:
cat /tmp/1.txt /tmp/2.txt
中
cat 就entrypoint
/tmp/1.txt /tmp/2.txt 就是两个参数, 因为args 是1个list
又如:
echo abc def
中, echo 是 entrypoint, args 是 [abc, def]
所以在clouldbuild.yaml 中下面command 1是正确的, command 2 是错误的
steps:# correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# wrong- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: echo abcargs: [ def ]logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#optionslogging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging
因为第2中写法, 它把 echo abc 作为endpoint, 虽然合并字符串 也是 echo abc def, 跟 command 1 的写法一样, 但是yaml 中命令的写法绝对不是字符串
而镜像中的 /usr/bin 中绝对不可能有1个 echo abc 包括空格的file, 所以会出错
日志
starting build "34e39f7f-e039-4572-a392-21a154ed8228"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717185531.688094-1bcec1bbcfb64618b377c2a5e097c551.tgz#1717185513807965
Copying gs://jason-hsbc_cloudbuild/source/1717185531.688094-1bcec1bbcfb64618b377c2a5e097c551.tgz#1717185513807965...
/ [0 files][ 0.0 B/ 73.9 KiB]
-
- [1 files][ 73.9 KiB/ 73.9 KiB]
Operation completed over 1 objects/73.9 KiB.
tar: cloudbuild-test.yaml: time stamp 2024-05-31 19:58:47.9453259 is 4.465130295 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc def
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Finished Step #1 - "test command 2"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: starting step container failed: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "echo abc": executable file not found in $PATH: unknown
使用 bash - c 命令
如果我们想执行 cat 命令 则需要把entrypoint set 成 cat, 不是echo
而其实我们可以用bash entrypoint 统一起来
我们先看下 -c 作用
-c If the -c option is present, then commands are read from the first non-option argument command_string. If there are arguments after the command_string, the first argument is assigned to $0 and any remaining arguments are assigned to the positional parameters. The assignment to $0 sets the name of the shell, which is used in warning and error messages.
不是那么好懂, 举个例子:
[gateman@manjaro-x13 mkinitcpio.d]$ bash -c 'echo $1 $0' abc def
def abc
bash -c 后面第1个参数 就是要执行的命令, 但是这个参数要用单引号(不是双引号) 来包住, 第2个参数开始, 都是第1个参数(被执行命令)
注意, 单引号不要写成双引号, 否则, 参数可能获取失败, $0 会被赋予 shell name
[gateman@manjaro-x13 mkinitcpio.d]$ bash -c "echo $1 $0" abc def
/bin/bash
总之, bash -c 只会执行1条命令, 第2个参数开始都是第1个参数的子参数
如果想一次执行两条命令, 下面是错误示范
[gateman@manjaro-x13 mkinitcpio.d]$ bash -c 'echo abc' 'echo def'
abc
因为它把 ‘echo def’ 作为 ‘echo abc’ 的参数, 并没有被执行
正确写法:
[gateman@manjaro-x13 demo_cloud_user]$ bash -c 'echo abc; echo def'
abc
def
对于cloudbuild 来讲, 我们也可以用bash -c 的写法来编写 entrypoint 和 args
steps:# correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo abc def ]# incorrect nothing output- id: test command 3name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo , abc def ]# correct- id: test command 4name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo $0 , abc def ]# correct- id: test command 5name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo $0 $1 , abc, def ]logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#optionslogging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging
注意第3种写法是错误的, abc def 作为 ‘echo’ 的参数毫无效果
输出:
starting build "e234fd52-bfe2-4c5a-91c0-6980ef6db448"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717245688.299578-00e798950592461f9661290baa21addd.tgz#1717245670180704
Copying gs://jason-hsbc_cloudbuild/source/1717245688.299578-00e798950592461f9661290baa21addd.tgz#1717245670180704...
/ [0 files][ 0.0 B/ 73.9 KiB]
-
- [1 files][ 73.9 KiB/ 73.9 KiB]
Operation completed over 1 objects/73.9 KiB.
tar: cloudbuild-test.yaml: time stamp 2024-06-01 12:41:24.1218889 is 4.953891927 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc def
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "test command 2": abc def
Finished Step #1 - "test command 2"
Starting Step #2 - "test command 3"
Step #2 - "test command 3": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #2 - "test command 3":
Finished Step #2 - "test command 3"
Starting Step #3 - "test command 4"
Step #3 - "test command 4": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #3 - "test command 4": abc def
Finished Step #3 - "test command 4"
Starting Step #4 - "test command 5"
Step #4 - "test command 5": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #4 - "test command 5": abc def
Finished Step #4 - "test command 5"
PUSH
DONE
对于args 使用另1种的数组写法
众所周知, 在yaml 中, 数组有两种表示方式
1是 中括号模式
例如:
args: [abc, def]args:- abc- def
上面那种写法是正确的
对于本文里例子, couldbuild.yaml 命令也可以写成
# correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo abc def ]# correct- id: test command 3name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- echo abc def
上面3种写法都是等价的
对于多条命令的另1种写法
例如我想连续执行两条命令
echo abc 和 head /etc/proc/cpuinfo
这时entrypoint 就不能是 echo 和 head, 只能是bash
写法1:
- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- echo abc; head /proc/cpuinfo
主要用分号隔开, 如果真的想写成两行
则写法2, 用| 表示 ,则两行之间不需要写 ; 但是他们其实加起来还是args 的1个参数, 并不是两个
# correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- |echo abchead /proc/cpuinfo
输出是一样的
starting build "5733316f-83e9-4566-98fd-f33fca535eda"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717249155.147565-a60f825e1e024b9eb1fc4529b01cf417.tgz#1717249137259618
Copying gs://jason-hsbc_cloudbuild/source/1717249155.147565-a60f825e1e024b9eb1fc4529b01cf417.tgz#1717249137259618...
/ [0 files][ 0.0 B/ 73.9 KiB]
-
- [1 files][ 73.9 KiB/ 73.9 KiB]
Operation completed over 1 objects/73.9 KiB.
tar: cloudbuild-test.yaml: time stamp 2024-06-01 13:39:13.706183 is 8.186919054 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc
Step #0 - "test command 1": processor : 0
Step #0 - "test command 1": vendor_id : GenuineIntel
Step #0 - "test command 1": cpu family : 6
Step #0 - "test command 1": model : 79
Step #0 - "test command 1": model name : Intel(R) Xeon(R) CPU @ 2.20GHz
Step #0 - "test command 1": stepping : 0
Step #0 - "test command 1": microcode : 0xffffffff
Step #0 - "test command 1": cpu MHz : 2199.998
Step #0 - "test command 1": cache size : 56320 KB
Step #0 - "test command 1": physical id : 0
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "test command 2": abc
Step #1 - "test command 2": processor : 0
Step #1 - "test command 2": vendor_id : GenuineIntel
Step #1 - "test command 2": cpu family : 6
Step #1 - "test command 2": model : 79
Step #1 - "test command 2": model name : Intel(R) Xeon(R) CPU @ 2.20GHz
Step #1 - "test command 2": stepping : 0
Step #1 - "test command 2": microcode : 0xffffffff
Step #1 - "test command 2": cpu MHz : 2199.998
Step #1 - "test command 2": cache size : 56320 KB
Step #1 - "test command 2": physical id : 0
Finished Step #1 - "test command 2"
PUSH
DONE
相关文章:
Google Cloudbuild yaml file 中 entrypoint 和 args 的写法
编写cloudbuild.yaml 时有几个关键参数 entrypoint 和 args 的基本介绍 id: 显示在 cloud build logs 里的item 名字 name: docker 镜像名字 - 下面的命令会在这个镜像的1个容器instance 内执行 entrypoint: 执行的命令入口 , 只能有1个对象 args: 命名…...

鸿蒙开发接口图形图像:【@ohos.window (窗口)】
窗口 窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。 该模块提供以下窗口相关的常用功能: [Window]:当前窗口实例,窗口管理器管理的基本单元。[WindowStage]&…...
LLM 基准测试的深入指南
随着越来越多的 LLM 可用,对于组织和用户来说,快速浏览不断增长的环境并确定哪些模型最适合他们的需求至关重要。实现这一目标的最可靠方法之一是了解基准分数。 考虑到这一点,本指南深入探讨了 LLM 基准的概念、最常见的基准是什么以及它们需要什么,以及仅依赖基准作为模…...
深入理解Redis事务、事务异常、乐观锁、管道
Redis事务与MySQL事务 不一样。原子性:MySQL有Undo Log机制,支持强原子性,和回滚。Redis只能保证事务内指令可以不被干扰的在同一批次执行,且没有机制保证全部成功则提交,部分失败则回滚。隔离性:MySQL的隔…...

17、Spring系列-SpringMVC-请求源码流程
前言 Spring官网的MVC模块介绍: Spring Web MVC是基于Servlet API构建的原始Web框架,从一开始就已包含在Spring框架中。正式名称“ Spring Web MVC”来自其源模块的名称(spring-webmvc),但它通常被称为“ Spring MVC…...
对简单工厂模式、工厂方法模式、抽象工厂模式的简单理解
简单工厂模式 三部分组成 抽象类一些抽象类的具体实现类工厂类 把创建对象的任务交给一个工厂类来实现,对业务进行封装。 优点:实现了任务分离,客户端不用关心业务的具体实现,交由工厂来“生产”。 缺点:违背开闭原…...

PostgreSQL常用插件
PostgreSQL 拥有许多常用插件,这些插件可以大大增强其功能和性能。以下是一些常用的 PostgreSQL 插件: 性能监控和优化 pg_stat_statements 1.提供对所有 SQL 语句执行情况的统计信息。对调优和监控非常有用。 2.安装和使用: pg_stat_k…...

mysql表字段超过多少影响性能 mysql表多少效率会下降
一直有传言说,MySQL 表的数据只要超过 2000 万行,其性能就会下降。而本文作者用实验分析证明:至少在 2023 年,这已不再是 MySQL 表的有效软限制。 传言 互联网上有一则传言说,我们应该避免单个 MySQL 表中的数据超过 …...

Vue进阶之Vue无代码可视化项目(一)
Vue无代码可视化项目 项目搭建初始步骤拓展:工程项目从0-1项目规范化package.jsoncpell.jsoncustom-words.txtts-eslint规则.eslintrc.cjsgit钩子检查有没有问题type-checkspellchecklint:stylehusky操作安装pre-commitpnpm的commit规范package.json:commitlint.config.cjs安装…...

初识C++ · 模拟实现list
目录 前言 1 push_back pop_back 2 迭代器类 2.1 ! 2.2 -- 2.3 * 3 Print_List 4 有关自定义类型 5 有关const迭代器 6 拷贝构造 赋值 析构 Insert erase 前言 有了string,vector的基础,我们模拟实现list还是比较容易的,这里同…...
电商运营-2024年6月1日
作为一名电商运营,针对淘工厂平台,需要具备以下核心技能和素质: 核心技能 新店入驻与产品管理 熟练掌握淘工厂平台的新店入驻流程,包括资质准备、资料提交、审核跟进等。精通产品上架技巧,确保产品信息准确、图片清晰…...

Go跨平台编译
1.编译windows平台运行程序 # windows env GOOSwindows GOARCHamd64 go build main.go2.编译linux平台运行程序 # linux env GOOSlinux GOARCHamd64 go build main.go 3.编译macos平台运行程序 # macos env GOOSdarwin GOARCHamd64 go build main.go 编译结果:...
生产计划排产,制定每小时计划产量(“查表法”SQL计算)
根据日生产计划产量排产,制定每2小时理论计划生产产量。 每2小时计划产量 每2小时工作时间(秒)/生产计划节拍(秒)。 假设,生产计划节拍 : 25.0(秒)/台 工厂以每天8点00分钟作为当日工作日的…...

视频汇聚管理安防监控平台EasyCVR程序报错“create jwtSecret del server class:0xf98b6040”的原因排查与解决
国标GB28181协议EasyCVR安防视频监控平台可以提供实时远程视频监控、视频录像、录像回放与存储、告警、语音对讲、云台控制、平台级联、磁盘阵列存储、视频集中存储、云存储等丰富的视频能力,平台支持7*24小时实时高清视频监控,能同时播放多路监控视频流…...
头歌页面置换算法第2关:计算OPT算法缺页率
2 任务:OPT算法 2.1 任务描述 设计OPT页面置换算法模拟程序:从键盘输入访问串。计算OPT算法在不同内存页框数时的缺页数和缺页率。要求程序模拟驻留集变化过程,即能模拟页框装入与释放过程。 2.2任务要求 输入串长度作为总页框数目,补充程序完成OPT算法。 2.3算法思路 OPT算…...

vscode怎么拷贝插件到另一台电脑
说明 vscode插件默认存放在 C:\Users\用户名\.vscode 目录下的 extensions 文件夹中 方法 拷贝 C:\Users\用户名\.vscode 目录下的 extensions 文件夹到另一台电脑的C:\Users\用户名\.vscode 目录下 C:\Users\用户名\.vscode...

网络协议分析
网络协议分析 网络协议分析概述用IP实现异构网络互联网络协议的分层TCP/IP的分层模型协议分析协议分析应用协议分析任务 常见网络协议PPP协议报文选项IPCP认证协议PAP安全缺陷认证协议CHAPPPPoE协议流程 地址解析协议ARPARP的思想和步骤ARP报文格式及封装 移动IP移动IP的工作机…...
GAMIT目录配置
1打开home,显示隐藏文件,CTRH 2修改目录 #set gamitpath gamitpath/opt/gamit10.7 export PATH$PATH:${gamitpath}/com/:${gamitpath}/gamit/bin:${gamitpath}/kf/bin HELP_DIR${gamitpath}/help export HELP_DIR #set GMT path gmtpath/usr/lib/gmt P…...

基于JSP的九宫格日志网站
你好呀,我是学长猫哥!如果有需求可以文末加我。 开发语言:Java 数据库:MySQL 技术:JSP技术 工具:浏览器/服务器(B/S)结构 系统展示 首页 管理员功能模块 用户功能模块 摘要 本…...

C#中结构struct能否继承于一个类class,类class能否继承于一个struct
C#中结构struct能否继承于一个类class,类class能否继承于一个struct 答案是:都不能。 第一种情行,尝试结构继承类 报错:接口列表中的类型"XX"不是接口interface。 一般来说,都是结构只能实现接口&#x…...
Android Wi-Fi 连接失败日志分析
1. Android wifi 关键日志总结 (1) Wi-Fi 断开 (CTRL-EVENT-DISCONNECTED reason3) 日志相关部分: 06-05 10:48:40.987 943 943 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid44:9b:c1:57:a8:90 reason3 locally_generated1解析: CTR…...

python打卡day49
知识点回顾: 通道注意力模块复习空间注意力模块CBAM的定义 作业:尝试对今天的模型检查参数数目,并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...

YSYX学习记录(八)
C语言,练习0: 先创建一个文件夹,我用的是物理机: 安装build-essential 练习1: 我注释掉了 #include <stdio.h> 出现下面错误 在你的文本编辑器中打开ex1文件,随机修改或删除一部分,之后…...

深入理解JavaScript设计模式之单例模式
目录 什么是单例模式为什么需要单例模式常见应用场景包括 单例模式实现透明单例模式实现不透明单例模式用代理实现单例模式javaScript中的单例模式使用命名空间使用闭包封装私有变量 惰性单例通用的惰性单例 结语 什么是单例模式 单例模式(Singleton Pattern&#…...
在四层代理中还原真实客户端ngx_stream_realip_module
一、模块原理与价值 PROXY Protocol 回溯 第三方负载均衡(如 HAProxy、AWS NLB、阿里 SLB)发起上游连接时,将真实客户端 IP/Port 写入 PROXY Protocol v1/v2 头。Stream 层接收到头部后,ngx_stream_realip_module 从中提取原始信息…...

涂鸦T5AI手搓语音、emoji、otto机器人从入门到实战
“🤖手搓TuyaAI语音指令 😍秒变表情包大师,让萌系Otto机器人🔥玩出智能新花样!开整!” 🤖 Otto机器人 → 直接点明主体 手搓TuyaAI语音 → 强调 自主编程/自定义 语音控制(TuyaAI…...

智能分布式爬虫的数据处理流水线优化:基于深度强化学习的数据质量控制
在数字化浪潮席卷全球的今天,数据已成为企业和研究机构的核心资产。智能分布式爬虫作为高效的数据采集工具,在大规模数据获取中发挥着关键作用。然而,传统的数据处理流水线在面对复杂多变的网络环境和海量异构数据时,常出现数据质…...

AI,如何重构理解、匹配与决策?
AI 时代,我们如何理解消费? 作者|王彬 封面|Unplash 人们通过信息理解世界。 曾几何时,PC 与移动互联网重塑了人们的购物路径:信息变得唾手可得,商品决策变得高度依赖内容。 但 AI 时代的来…...
【Go语言基础【12】】指针:声明、取地址、解引用
文章目录 零、概述:指针 vs. 引用(类比其他语言)一、指针基础概念二、指针声明与初始化三、指针操作符1. &:取地址(拿到内存地址)2. *:解引用(拿到值) 四、空指针&am…...
C++.OpenGL (20/64)混合(Blending)
混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...