如何在Openshift中为构建配置提供多个源输入

问题描述 投票:0回答:1

我想创建一个构建器图像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": {}
            }
        ]
    }
}
openshift buildconfig
1个回答
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"
                    }
                ]
            },
            ...
    },
}, 

直接添加到原始构建配置时,您可以拥有多个图像源。命令行只允许设置一个。

© www.soinside.com 2019 - 2024. All rights reserved.