我想创建一个构建器image 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": {}
}
]
}
}
您可以使用所谓的链式版本。
使用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"
}
]
},
...
},
},
直接添加到原始构建配置时,您可以具有多个图像源。命令行只允许设置一个。