第 1 章 构建概述
构建是基于 Shipwright 项目的 可扩展构建框架,可用于在 OpenShift Container Platform 集群上构建容器镜像。您可以使用镜像构建工具(如 Source-to-Image (S2I)和 Buildah
)从源代码和 Dockerfile 构建容器镜像。您可以创建并应用构建资源,查看构建运行日志,并管理 OpenShift Container Platform 命名空间中的构建。
构建包括以下功能:
- 标准 Kubernetes 原生 API,用于从源代码和 Dockerfile 构建容器镜像
-
支持 Source-to-Image (S2I)和
Buildah
构建策略 - 使用您自己的自定义构建策略的可扩展性
- 从本地目录中的源代码执行构建
- 用于创建和查看日志的 Shipwright CLI,并管理集群上的构建
- 使用 OpenShift Container Platform Web 控制台的 Developer 视角集成用户体验
构建由以下自定义资源(CR)组成:
-
Build
-
BuildStrategy
和ClusterBuildStrategy
-
BuildRun
1.1. 构建资源
Build
资源定义应用程序的源代码以及应用镜像的位置。以下示例显示了一个简单的构建,它由 Git 源、构建策略和输出镜像组成:
apiVersion: shipwright.io/v1beta1 kind: Build metadata: name: buildah-golang-build spec: source: git: url: https://github.com/username/taxi strategy: name: buildah kind: ClusterBuildStrategy output: image: registry.mycompany.com/my-org/taxi-app:latest
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build
spec:
source:
git:
url: https://github.com/username/taxi
strategy:
name: buildah
kind: ClusterBuildStrategy
output:
image: registry.mycompany.com/my-org/taxi-app:latest
Copy to clipboardCopied
您还可以扩展 Build
资源,以将镜像推送到私有 registry 或使用 Dockerfile。