Create coscmd

This commit is contained in:
Stille 2021-06-25 18:24:06 +08:00
parent 9544e22b0e
commit bf4a29473d
3 changed files with 97 additions and 0 deletions

44
.github/workflows/coscmd.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: "coscmd docker build"
env:
PROJECT: coscmd
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set tag
id: tag
run: |
if [[ -n $(cat ${{ env.PROJECT }}/Dockerfile | awk '{if($2~"VERSION")print $3}') ]]; then
VERSION=$(cat ${{ env.PROJECT }}/Dockerfile | awk '{if($2~"VERSION")print $3}')
echo "tag=$VERSION" >> $GITHUB_ENV
else
echo "tag=$(date +%Y)-$(date +%m)-$(date +%d)" >> $GITHUB_ENV
fi
- name: Docker Hub login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
buildx-version: latest
- name: Build Dockerfile
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
docker buildx build \
--platform=linux/amd64,linux/arm64 \
--output "type=image,push=true" \
--file ${{ env.PROJECT }}/Dockerfile ./${{ env.PROJECT }} \
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ env.PROJECT }}:latest \
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ env.PROJECT }}:${{ env.tag }}

7
coscmd/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM python:2
MAINTAINER Stille <stille@ioiox.com>
ENV VERSION 1.8.6.24
RUN pip install coscmd

46
coscmd/README.md Normal file
View File

@ -0,0 +1,46 @@
# coscmd
GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles)
Docker [stilleshan/coscmd](https://hub.docker.com/r/stilleshan/coscmd)
> *docker image support for X86 and ARM*
## 简介
基于 [腾讯云 COSCMD 工具](https://cloud.tencent.com/document/product/436/10976) 的 docker 镜像.
## 更新
**2021-06-25** 更新 docker 镜像,已测试同时支持 X86 和 ARM 架构.
## 使用
腾讯云 COSCMD 工具 docker 镜像用于启动一次性容器来完成单次的上传或下载需求.
### 配置文件
参考 [官方文档](https://cloud.tencent.com/document/product/436/10976) 创建`.cos.conf`配置文件.
```conf
[common]
secret_id = AKIDA6wUmImTMzvXZNbGLCgtusZ2E8mG****
secret_key = TghWBCyf5LIyTcXCoBdw1oRpytWk****
bucket = configure-bucket-1250000000
region = ap-chengdu
max_thread = 5
part_size = 1
retry = 5
timeout = 60
schema = https
verify = md5
anonymous = False
```
### docker
挂载`.cos.conf`配置文件至容器内`/root/.cos.conf`以及本地需要上传或下载的目录.
```shell
docker run --rm \
-v /path/.cos.conf:/root/.cos.conf \
-v /data:/data \
stilleshan/coscmd \
coscmd upload -rfs --delete /data /dst_data
```
## 参考
- [腾讯云 COSCMD 工具](https://cloud.tencent.com/document/product/436/10976)
- [COSCMD 工具类常见问题](https://cloud.tencent.com/document/product/436/30744)