Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add build-and-push-wasm-plugin-image.yaml #1069

Merged
merged 15 commits into from
Jul 8, 2024
Merged

Conversation

Beatrueman
Copy link
Contributor

@Beatrueman Beatrueman commented Jun 29, 2024

Ⅰ. Describe what this PR did

功能:添加了利用 GitHub Actions 来自动完成相应的镜像构建和发布工作的Workflow。支持通过push tag和手动触发两种方式。同时也遵循使用oras打包工具。
特点:完全按照Wasm 插件镜像规范进行镜像打包。

更新:

  1. 添加了查找文件的逻辑,会在插件目录中查找spec.yamlREADME.mdREADME-{lang}.md三个文件,有则在打包推送镜像时设置相应的media type
  2. 修改了review后存在的问题。
  3. 修改了builder容器的启动命令为 docker run -itd --name builder xxx /bin/bash,之前使用sleep 99999是希望容器保持后台持续运行,这样只适合测试容器,不适合在生产环境中使用。
  4. 重新提交PR是因为错误地提交了一些没用的commit,不太会删除,担心破坏仓库并且为了保持PR整洁所以重新提交。

Ⅱ. Does this pull request fix one issue?

fixes #1052

Ⅳ. Describe how to verify it

1.准备工作
添加Repository Secrets和 Repository variables。
img
img
2.通过push tag触发,先查找相关文件,然后将特定的插件打包成镜像并推送至指定仓库。
image

image-20240629120147125

image-20240629125144171
image-20240629125028239
3.人工触发,指定插件名和版本号
51e1fc7ab267c66492ecbcfb43cd23d0image

Ⅴ. Special notes for reviews

这是我第一次参与开源贡献,希望能有所帮助!

本次贡献借助了通义灵码以及通义千问。
image
image
image
image

@CH3CHO CH3CHO self-requested a review July 3, 2024 14:48
Copy link
Collaborator

@CH3CHO CH3CHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体看上去没什么问题。明后天我会测一下各个场景。

fi

# 查找README.md
case "$(ls ${workspace}/README*.md 2>/dev/null)" in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么这里没有选择继续使用 -f 判定呢?

file_name=$(basename $file)
echo "$file_name exists"
lang=$(basename $file | sed 's/README_//; s/.md//')
push_command="$push_command ./$file_name:application/vnd.module.wasm.doc.v1.$lang+markdown"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 $lang 可以考虑转一下小写

@Beatrueman
Copy link
Contributor Author

Beatrueman commented Jul 8, 2024

@CH3CHO 我做出了修改,麻烦review。

  1. 纠正了打包容器的TinyGO版本为0.28.1,确保镜像可用。
  2. 修改了编译命令为tinygo build -o ./plugin.wasm -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' ./main.go,确保plugin.wasm可用。
  3. 修改push_command,最后设置plugin.tar.gzmedia type,确保其位于镜像最后一层。

验证

环境介绍

  • Kubernetes部署Higress,Gateway位于32459端口。
  • higress.yiiong.top解析至服务器。
  • Kubernetes部署了一个Nginx测试服务,增加一个hello.html,访问会返回Hello World!
  • 增加一个ingress

image-20240708124939848

image-20240708124900182

Github Action打包出镜像。

image-20240708124301572

途径一:通过配置清单部署打包好的request-block插件,拒绝访问/hello.html,可以看到成功被拒绝访问。

image-20240708125215025

途径二:通过控制台新增插件,同样可以拒绝访问。

20240708-125510

image-20240708125515152

image-20240708125542985

image-20240708125640304

@Beatrueman Beatrueman requested a review from CH3CHO July 8, 2024 10:18
Copy link
Collaborator

@CH3CHO CH3CHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Beatrueman Beatrueman requested a review from CH3CHO July 8, 2024 11:00
@CH3CHO CH3CHO merged commit 74ddbf0 into alibaba:main Jul 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

支持通过 GitHub Actions 来构建和发布 Wasm 插件镜像
2 participants