Fork Docker images between registries using GitHub Actions
Project description
Docker Images Pusher
使用Github Action将国外的Docker镜像转存到阿里云私有仓库,供国内服务器使用,免费易用
- 支持DockerHub, gcr.io, k8s.io, ghcr.io等任意仓库
- 支持最大40GB的大型镜像
- 使用阿里云的官方线路,速度快
leo03w 20240830
新增 api_hook.yaml 带参workflow, 支持api方式启动github action, 可传 原始镜像地址 和 目的镜像地址 两个参数
- 支持
streamlit形式提供web界面 - 支持
cli.py命令行工具调用
使用方式
pip install .
export github_token=your_token
docker-image-forker --help
配置文件
在项目根目录下创建 .env 配置文件, 参考 config.py 中定义的配置项进行设置
token为必须配置, 参考
workflow rest api doc
生成你的访问令牌, 建议 细粒度的个人访问令牌
配置 owner为你的github用户名, repo为你克隆此项目后的项目命名
todo
-
cli.py支持单位置参数 - 外部调用
cli.py配置文件读取不到问题 - 镜像目标位置 名称中
/替换为- - 客户端工具, 输入镜像名称, 自动从阿里云仓库克隆, 并重命名
- 封装可执行文件
视频教程:https://www.bilibili.com/video/BV1Zn4y19743/
作者:技术爬爬虾
B站,抖音,Youtube全网同名,转载请注明作者
使用方式
配置阿里云
登录阿里云容器镜像服务
https://cr.console.aliyun.com/
启用个人实例,创建一个命名空间(ALIYUN_NAME_SPACE)
访问凭证–>获取环境变量
用户名(ALIYUN_REGISTRY_USER)
密码(ALIYUN_REGISTRY_PASSWORD)
仓库地址(ALIYUN_REGISTRY)
Fork本项目
Fork本项目
启动Action
进入您自己的项目,点击Action,启用Github Action功能
配置环境变量
进入Settings->Secret and variables->Actions->New Repository secret
将上一步的四个值
ALIYUN_NAME_SPACE,ALIYUN_REGISTRY_USER,ALIYUN_REGISTRY_PASSWORD,ALIYUN_REGISTRY
配置成环境变量
添加镜像
打开images.txt文件,添加你想要的镜像
可以加tag,也可以不用(默认latest)
可添加 --platform=xxxxx 的参数指定镜像架构
可使用 k8s.gcr.io/kube-state-metrics/kube-state-metrics 格式指定私库
可使用 #开头作为注释
文件提交后,自动进入Github Action构建
使用镜像
回到阿里云,镜像仓库,点击任意镜像,可查看镜像状态。(可以改成公开,拉取镜像免登录)
在国内服务器pull镜像, 例如:
docker pull registry.cn-hangzhou.aliyuncs.com/shrimp-images/alpine
registry.cn-hangzhou.aliyuncs.com 即 ALIYUN_REGISTRY(阿里云仓库地址)
shrimp-images 即 ALIYUN_NAME_SPACE(阿里云命名空间)
alpine 即 阿里云中显示的镜像名
多架构
需要在images.txt中用 --platform=xxxxx手动指定镜像架构
指定后的架构会以前缀的形式放在镜像名字前面
镜像重名
程序自动判断是否存在名称相同, 但是属于不同命名空间的情况。 如果存在,会把命名空间作为前缀加在镜像名称前。 例如:
xhofe/alist
xiaoyaliu/alist
定时执行
修改/.github/workflows/docker.yaml文件
添加 schedule即可定时执行(此处cron使用UTC时区)
备注
通过API调用后,获取run_id
https://github.com/orgs/community/discussions/17389
PyPi packaging
twine==6.1.0 版本太新, 导致
❯ python -m twine check dist/*
Checking dist/dock_worker-0.0.0-py3-none-any.whl: ERROR InvalidDistribution: Invalid distribution metadata: unrecognized or malformed field 'license-file'
pip install "twine<6.0" -U
降到 5.1.1 好了
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dock_worker-0.0.0.tar.gz.
File metadata
- Download URL: dock_worker-0.0.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aef11657537df3549d70ea67ec47f5e77f50149fd1a04414c6fed946a25ca6b
|
|
| MD5 |
2aad29ef21dc3283519395b6065e7b74
|
|
| BLAKE2b-256 |
100fb1c5625667e6decd00d832f149da647d7a85ebfab995d41b77e66ce9411f
|
File details
Details for the file dock_worker-0.0.0-py3-none-any.whl.
File metadata
- Download URL: dock_worker-0.0.0-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c56a9e8283960277c50cb361ed301308717c11ebc8dcd96ea249d3bbdf24d75
|
|
| MD5 |
2bf3a074698737736c751011ea51102a
|
|
| BLAKE2b-256 |
e92ab041a4c82af7b857a7b0c7a9eea96428a13d9b73628fca6560117b2b1f1b
|