1 Star 0 Fork 15

baigj / eulerpublisher

forked from openEuler / eulerpublisher 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

EulerPublisher

eulerpublisher是Infra SIG提供的”一键式“自动构建和发布openEuler镜像的工具,主要覆盖以下场景:

  1. container images构建、发布
  2. cloud images构建、发布
  3. WSL images构建、发布

eulerpublisher仍处于开发过程中,目前已向PyPI上传软件包,请使用以下两种方式之一进行安装

  1. 下载源码到本地,执行
python setup.py install
  1. 使用pip安装,执行
pip install eulerpublisher

环境依赖

1.eulerpublisher实现多平台容器镜像构建功能依赖于docker和qemu,安装方式如下:

yum install qemu-img
yum install docker

多平台镜像构建使用docker buildx,安装的docker版本需满足>= 19.03或单独安装buildx插件,单独安装docker buildx方法如下:

1). 从Docker buildx项目的release页面找到适合自己平台的二进制文件。

2). 下载二进制文件到本地并重命名为docker-buildx,移动到docker的插件目录~/.docker/cli-plugins

3). 向二进制文件授予可执行权限chmod +x ~/.docker/cli-plugins/docker-buildx

2.eulerpublisher使用python实现,依赖见requirement.txt,安装如下:

pip install -r ./requirement.txt

使用说明

1. 发布容器镜像

基础容器镜像

本部分介绍如何使用eulerpublisher发布多平台(支持amd64和arm64)openeuler基础容器镜像(区分于应用镜像,如AI容器镜像)。该功能可用于eulerpublisher从openeuler官方获取容器镜像,进行二次定制后发布至第三方仓库,镜像产品的tag严格遵守oEEP-0005的规范。

  • 步骤1 、获取构建基础镜像的必要文件
eulerpublisher container base prepare --version {VERSION} --index {INDEX}

这个命令中--version必须显式指定,用于获取对应版本的构建所需文件。 --index指定官方镜像的路径,可选docker_imgdocker_img/update/Y-M-D, 选择docker_img表明获取openeuler的release版本、选择docker_img/update/Y-M-D表明获取update版本,不显式指定时默认获取release版本进行二次定制。

  • 步骤2 、构建并push镜像到目标仓库

执行本步之前,需要先配置push的目标仓库username和password的环境变量用以登陆,确保push可以成功,执行

export LOGIN_USERNAME="username"
export LOGIN_PASSWORD="password"

完成上述步骤1并配置LOGIN_USERNAMELOGIN_PASSWORD之后,可执行如下命令进行build和push

eulerpublisher container base push --repo {REPO} --version {VERSION} --registry {REGISTRY} --dockerfile {DOCKERFILE}

此命令中,--repo--version必须显式指定,--registry不显式指定时默认指向dockerhub (https://hub.docker.com),--dockerfile指定自定义dockerfile的路径,不显式指定时使用默认Dockerfile。由于docker buildx build构建的多平台image无法在本地缓存,build的时候必须同步push到对应repo(可以是私有的)。因此,有测试需求的情况下,尽量先将构建的container image push到私有仓库验证完成后再publish到最终目标仓库。

  • 步骤3 、测试基础容器镜像
eulerpublisher container base check --tag {TAG} --script {SCRIPT.sh}

上述命令将对标签为{TAG}的基础容器镜像进行测试。 EulerPublisher使用shUnit2框架进行容器镜像测试,基础容器镜像的测试用例默认保存在tests/container/base/openeuler_test.sh,用户可根据自身需求使用--script调整测试用例。

  • 一键发布
# 向单个仓库发布容器镜像:
eulerpublisher container base publish --repo {REPO} --version {VERSION} --index {INDEX} --registry {REGISTRY} --dockerfile {Dockerfile}

此命令是上述步骤1~2的顺序功能集合,每个参数的含义与上述相同。使用示例如下

示例:
eulerpublisher container base publish --repo openeuler/openeuler --version 22.03-LTS-SP1 --registry registry-1.docker.io --dockerfile Dockerfile

上述执行的效果是向dockerhub(https://hub.docker.com)的openeuler/openeuler仓库发布由Dockerfile定制的tag为22.03-LTS-SP1的支持arm64、amd64多平台的openeuler基础容器镜像。

为了方便将一个镜像同时发布到多个仓库,可使用如下命令:

# 向多个仓库发布容器镜像:
eulerpublisher container base publish --version {VERSION} --index {INDEX}  --dockerfile {Dockerfile} --mpublish

此命令使用--mpublish使能"publish one image to multiple repositories", 不再需要设置--repo--registry参数。目标repositories的信息由yaml文件决定,用户通过配置环境变量EP_LOGIN_FILE来指定该文件的路径。默认的目标repositories信息由config/container/base/registry.yaml指定,内容如下

# registry.yaml内容示例
registry-1:
  - LOGIN_USER_1
  - LOGIN_PASSWD_1
  - registry-1/{USER_1}/{REPOSITORY-1}

registry-2:
  - LOGIN_USER_2
  - LOGIN_PASSWD_2
  - registry-2/{USER_2}/{REPOSITORY-2}

  ...

其中每个仓库都维护一组信息,{LOGIN_USER_1}和{LOGIN_PASSWD_1}分别是登录registry-1的用户名和密码的环境变量(发布之前需要通过export配置正确的用户和密码),registry-1/{USER_1}/{REPOSITORY-1}是完整的仓库路径,其他仓库的信息也是如此。

应用容器镜像

openEuler应用容器镜像是在基础容器镜像之上包含特定场景的应用软件,向用户提供开箱即用的开发、使用体验,例如AI容器镜像(见oEEP-0014)。

# 应用容器镜像发布
eulerpublisher container app publish --arch aarch64 --repo openeuler/cann --dockerfile Dockerfile --tag cann7.0.0.aplha002-oe2203sp2
# 应用容器镜像测试
eulerpublisher container app check --name {APP_NAME} --script {SCRIPT.sh} --tag {APP_TAG}

应用容器镜像的测试用例默认保存在tests/container/app/{APP_NAME}_test.sh,用户可根据自身需求使用--script调整测试用例。

测试框架

EulerPublisher使用shunit2测试框架。

2. 构建cloud images

通用云镜像构建

使用eulerpublisher在本地执行机上进行通用云镜像构建,定制的镜像符合大多数主流云厂商镜像发布的要求,可用于发布。

  • 步骤1 、基础构建准备
eulerpublisher cloudimg gen prepare --version {VERSION} --arch {ARCH}

此命令中所有参数均需显式指定,--version是构建目标镜像的openEuler版本号,--arch指定构建目标镜像的架构类型,目前仅支持aarch64x86_86, 该步骤实现的功能是从openEuler Repo获取基础镜像,用于下一步定制。

  • 步骤2 、构建通用镜像
eulerpublisher cloudimg gen build --version {VERSION} --arch {ARCH} --output {NAME} --rpmlist {RPMLIST}

此命令中{NAME}指定最终构建镜像的名称,{RPMLIST}是用户需要预安装的软件包列表文件,一旦指定不能为空。其余参数作用与步骤1命令中参数作用一致。

# rpmlist内容示例
tar
make
zip
curl
...

执行此命令后,会在执行机/tmp/eulerpublisher/cloudimg/gen/output/目录下生成一个命名为{NAME}的最终镜像,该镜像满足目前大多数主流公有云厂商云市场镜像发布的技术要求,用户可手动进行镜像发布。

AWS云镜像构建

使用eulerpublisher构建AMI时,需要预先使用awscli进行aws configure配置,完成身份认证,配置信息如下:

$ aws configure
- AWS Access Key ID: <key_id>
- AWS Secret Access Key: <secret_key>
- Default region name: <region>

其中,key_idsecret_key是一对用于访问认证的密钥对,生成方法参见AWS管理访问密钥region是执行构建AMI任务的域。

  • 步骤1 、AMI构建准备
eulerpublisher cloudimg aws prepare --version {VERSION} --arch {ARCH} --bucket {BUCKET}

此命令中所有参数均需显式指定,--version是构建目标AMI的openEuler版本号,--arch指定构建AMI的架构类型,目前仅支持aarch64x86_86--bucket是存储桶名,存储桶用于保存prepare上传的原始raw镜像,bucketaws configure配置的region内。

执行此命令后,会在AWS对应regionbucket中出现一个命名为openEuler-{VERSION}-{ARCH}.raw的原始镜像(例如:openEuler-22.03-LTS-SP2-x86_64.raw)。

  • 步骤2 、构建AMI
eulerpublisher cloudimg aws build --version {VERSION} --arch {ARCH} --bucket {BUCKET} --region {REGION} --rpmlist {RPMLIST}

此命令中除--rpmlist以外的所有参数均需显式指定,参数作用与eulerpublisher cloudimg aws prepare命令一致。eulerpublisher通过aws_install.sh实现定制AMI镜像的能力,目前默认的aws_install.sh满足构建得到的AMI符合AWS Marketplace AMI发布的要求,需要预安装到镜像中的软件由--rpmlist指定的文件{RPMLIST}确定。

# rpmlist示例
tar
make
zip
curl
...

执行此命令后,会在AWS对应regionEC2 AMI列表中生成一个命名为openEuler-{VERSION}-{ARCH}-{TIME}-hvm的最终镜像(例如:openEuler-22.03-LTS-SP2-x86_64-20230802_010324-hvm)。

  • 发布AMI到AWS Marketplace

同时,eulerpublisher提供“一键发布”到AWS个人账户的能力,即上述步骤1、2的顺序执行,命令如下:

eulerpublisher cloudimg aws publish --version {VERSION} --arch {ARCH} --bucket {BUCKET} --region {REGION} --rpmlist {RPMLIST}

生成的AMI满足AWS Marketplace云镜像发布的要求,如有需要可进行镜像产品发布。由于AWS Marketplace存在人工审核环节,无法通过自动化流程一键发布,用户需手动操作申请发布AMI,见https://aws.amazon.com/marketplace

木兰宽松许可证, 第2版 木兰宽松许可证, 第2版 2020年1月 http://license.coscl.org.cn/MulanPSL2 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 0. 定义 “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体”是指提交贡献的机构及其“关联实体”。 “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 6. 语言 “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 条款结束 如何将木兰宽松许可证,第2版,应用到您的软件 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.

简介

A tool to publish openeuler docker and cloud images. 展开 收起
MulanPSL-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/baigj/eulerpublisher.git
git@gitee.com:baigj/eulerpublisher.git
baigj
eulerpublisher
eulerpublisher
master

搜索帮助