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…...
R语言AI模型部署方案:精准离线运行详解
R语言AI模型部署方案:精准离线运行详解 一、项目概述 本文将构建一个完整的R语言AI部署解决方案,实现鸢尾花分类模型的训练、保存、离线部署和预测功能。核心特点: 100%离线运行能力自包含环境依赖生产级错误处理跨平台兼容性模型版本管理# 文件结构说明 Iris_AI_Deployme…...

Mybatis逆向工程,动态创建实体类、条件扩展类、Mapper接口、Mapper.xml映射文件
今天呢,博主的学习进度也是步入了Java Mybatis 框架,目前正在逐步杨帆旗航。 那么接下来就给大家出一期有关 Mybatis 逆向工程的教学,希望能对大家有所帮助,也特别欢迎大家指点不足之处,小生很乐意接受正确的建议&…...

《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (一)
CSI-2 协议详细解析 (一) 1. CSI-2层定义(CSI-2 Layer Definitions) 分层结构 :CSI-2协议分为6层: 物理层(PHY Layer) : 定义电气特性、时钟机制和传输介质(导线&#…...

SCAU期末笔记 - 数据分析与数据挖掘题库解析
这门怎么题库答案不全啊日 来简单学一下子来 一、选择题(可多选) 将原始数据进行集成、变换、维度规约、数值规约是在以下哪个步骤的任务?(C) A. 频繁模式挖掘 B.分类和预测 C.数据预处理 D.数据流挖掘 A. 频繁模式挖掘:专注于发现数据中…...

[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?
论文网址:pdf 英文是纯手打的!论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误,若有发现欢迎评论指正!文章偏向于笔记,谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...

【快手拥抱开源】通过快手团队开源的 KwaiCoder-AutoThink-preview 解锁大语言模型的潜力
引言: 在人工智能快速发展的浪潮中,快手Kwaipilot团队推出的 KwaiCoder-AutoThink-preview 具有里程碑意义——这是首个公开的AutoThink大语言模型(LLM)。该模型代表着该领域的重大突破,通过独特方式融合思考与非思考…...

AI书签管理工具开发全记录(十九):嵌入资源处理
1.前言 📝 在上一篇文章中,我们完成了书签的导入导出功能。本篇文章我们研究如何处理嵌入资源,方便后续将资源打包到一个可执行文件中。 2.embed介绍 🎯 Go 1.16 引入了革命性的 embed 包,彻底改变了静态资源管理的…...

均衡后的SNRSINR
本文主要摘自参考文献中的前两篇,相关文献中经常会出现MIMO检测后的SINR不过一直没有找到相关数学推到过程,其中文献[1]中给出了相关原理在此仅做记录。 1. 系统模型 复信道模型 n t n_t nt 根发送天线, n r n_r nr 根接收天线的 MIMO 系…...
Redis的发布订阅模式与专业的 MQ(如 Kafka, RabbitMQ)相比,优缺点是什么?适用于哪些场景?
Redis 的发布订阅(Pub/Sub)模式与专业的 MQ(Message Queue)如 Kafka、RabbitMQ 进行比较,核心的权衡点在于:简单与速度 vs. 可靠与功能。 下面我们详细展开对比。 Redis Pub/Sub 的核心特点 它是一个发后…...

【分享】推荐一些办公小工具
1、PDF 在线转换 https://smallpdf.com/cn/pdf-tools 推荐理由:大部分的转换软件需要收费,要么功能不齐全,而开会员又用不了几次浪费钱,借用别人的又不安全。 这个网站它不需要登录或下载安装。而且提供的免费功能就能满足日常…...