Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yaming116 committed Jun 8, 2024
1 parent 283eee6 commit 1b6ecda
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
docker login -u $ALIYUN_REGISTRY_USER -p $ALIYUN_REGISTRY_PASSWORD $REGISTRY
sh pull.sh
data=`cat trigger.txt`
curl -H 'Content-Type: application/json' \
-d "{\"msgtype\": \"text\",\"text\": {\"content\":\"同步成功 $data \"}}" \
$MM_NOTIFY_URL
if [-z $MM_NOTIFY_URL ];then
echo 'MM_NOTIFY_URL not set'
else
curl -H 'Content-Type: application/json' \
-d "{\"msgtype\": \"text\",\"text\": {\"content\":\"同步成功 $data \"}}" \
$MM_NOTIFY_URL
fi
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@

## 使用方式

**一定要看看**
**一定要看看**
**一定要看看**

当需要将某个镜像如 nginx:alpine 上传到私有仓库 registry.cn-beijing.aliyuncs.com/ijx-public/nginx:alpine

### 第一步
修改 `trigger.txt` 内容为
修改 `trigger.txt` 内容, 内容分为两部分,中间使用空格隔开, 目前每次代码提交都会触发镜像同步,需要注意

* 前面是需要同步的镜像
* 后面是上传到阿里云地址的镜像
* 第一部分是阿里云容器镜像仓库地址
* 第二部分是我们自己的命名空间地址
* 最后就是镜像名称和版本
```
nginx:alpine registry.cn-beijing.aliyuncs.com/ijx-public/nginx:alpine
```
Expand All @@ -17,20 +27,18 @@ nginx:alpine registry.cn-beijing.aliyuncs.com/ijx-public/nginx:alpine
提交 github 后,会触发 actions,等待 actions build 成功

### 第三步
若 build 成功,可以在本地拉取私有仓库的镜像,使用脚本自动修改 tag
```
curl -s https://github.jiyuhang.workers.dev/https://raw.githubusercontent.com/Ji-Yuhang/docker-pull-proxy/main/tag.sh -o tag.sh
若 build 成功,可以在本地拉取私有仓库的镜像

sh tag.sh
```

若需要 ansible ,可以使用如下脚本
```
curl -s https://github.jiyuhang.workers.dev/https://raw.githubusercontent.com/Ji-Yuhang/docker-pull-proxy/main/ansible.sh -o ansible.sh
如果阿里云在控制台没有登录,就需要登录下,在**阿里云个人凭证那里有登录命令**, 如果用户名被脱敏了,那注意修改下。
使用 docker 命令获取阿里云同步完的镜像,地址格式和 `trigger.txt` 后半部分内容一致的

```bash
# 下载镜像
docker pull registry.cn-beijing.aliyuncs.com/ijx-public/nginx:alpine

sh ansible.sh
# 如果需要把镜像名称改回去,可以这样
docker tag registry.cn-beijing.aliyuncs.com/ijx-public/nginx:alpine nginx:alpine
```

## TODO
- [] 查找并拉取已存在过的镜像
- [] 增加成功监听机制

0 comments on commit 1b6ecda

Please sign in to comment.