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 好了
Metadata
Release files for dock-worker 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dock_worker-0.0.0.tar.gz | 17.7 kB | Without provenance | Details for dock_worker-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dock_worker-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for dock_worker-0.0.0-py3-none-any.whl |
Total release size: 35.0 kB
Release files / dock_worker-0.0.0.tar.gz
| Download URL | dock_worker-0.0.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4aef11657537df3549d70ea67ec47f5e77f50149fd1a04414c6fed946a25ca6b
|
|
BLAKE2b-256 checksum How to use checksums |
100fb1c5625667e6decd00d832f149da647d7a85ebfab995d41b77e66ce9411f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / dock_worker-0.0.0-py3-none-any.whl
| Download URL | dock_worker-0.0.0-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c56a9e8283960277c50cb361ed301308717c11ebc8dcd96ea249d3bbdf24d75
|
|
BLAKE2b-256 checksum How to use checksums |
e92ab041a4c82af7b857a7b0c7a9eea96428a13d9b73628fca6560117b2b1f1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for dock-worker 0.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.