我想创建一个构建器图像app_name:latest
,它将采用多个源输入,例如另一个图像和二进制源,然后将输出创建为app_name:latest
。
示例 -
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "app_name",
"labels": {
"application": "app_name"
}
},
"spec": {
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/xyz/app_name.git",
"ref": "master"
},
"contextDir": ""
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"namespace": "openshift",
"name": "java-s2i:latest"
}
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "app_name:latest"
}
},
"triggers": [{
"type": "GitHub",
"generic": {
"secret": "secret"
}
},
{
"type": "Generic",
"github": {
"secret": "secret"
}
},
{
"type": "ImageChange",
"imageChange": {}
}
]
}
}
答案 0 :(得分:1)
您可以使用所谓的链式构建。
使用oc new-build
创建图像时,请使用以下选项:
--source-image='': Specify an image to use as source for the build. You must also specify --source-image-path.
--source-image-path='': Specify the file or directory to copy from the source image and its destination in the build directory. Format:
--source-image
的参数是从单独的构建创建的现有图像流的名称。这可能包含其他预编译的工件或数据文件。
--source-image-path
的参数是从中复制文件的图像中的绝对参数,以及源构建注入的上载文件目录中的相对路径名,其中应放置单独图像中的文件。后者不能是绝对路径,因此您必须覆盖assemble
脚本才能将其移动到正确的位置。
就原始构建配置中的情况而言,它是:
"source": {
"git": {
"ref": "master",
"uri": "https://github.com/jakevdp/PythonDataScienceHandbook"
},
"images": [
{
"from": {
"kind": "ImageStreamTag",
"name": "packages-python-27:latest"
},
"paths": [
{
"destinationDir": ".s2i",
"sourcePath": "/opt/app-root/packages"
}
]
},
{
"from": {
"kind": "ImageStreamTag",
"name": "packages-python-35-wheelhouse:latest"
},
"paths": [
{
"destinationDir": ".s2i",
"sourcePath": "/opt/app-root/packages"
}
]
},
...
},
},
直接添加到原始构建配置时,您可以拥有多个图像源。命令行只允许设置一个。