# compose_update **Repository Path**: yunwe/compose_update ## Basic Information - **Project Name**: compose_update - **Description**: 通过post请求更新docker-compose - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-06-12 - **Last Updated**: 2025-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: Go语言, Docker, docker-compose, devops, cicd ## README # ComposeUpdate ## 介绍 通过接口请求compose_update服务更新docker-compose文件镜像版本,建议搭配Jenkins使用。 ## 构建(可选) ```shell # 下载源码 git clone https://gitee.com/yunwe/compose_update.git cd compose_update/ # 设置国内代理(七牛云) go env -w GOPROXY=https://goproxy.cn,direct # 构建x86_64版本 GOOS=linux GOARCH=amd64 go build -o compose_update_amd64_linux ./app # 构建arm64版本 GOOS=linux GOARCH=arm64 go build -o compose_update_arm64_linux ./app ``` ## 安装教程 ### 环境要求 - Docker - Docker Compose ## 使用说明 选择对应架构下载后添加执行权限`chmod +x compose_update_amd64_linux` ### 启动参数 ```bash [root@master-test test]# ./compose_update_amd64_linux -h WARN[2025-04-15 05:36:08] 无效日志级别 '',默认使用'info' Usage of ./compose_update_amd64_linux: -filePath string The path of the docker-compose.yml file needs to be provided when the program is running or the interface is called. -listen string Port to listen on (default 5001) (default "5001") -loglevel string Log level (debug, info, warn, error, fatal, panic) (default "debug") -token string Authentication token. ``` ### 启动示例: ```bash ./compose_update_for_linux -token 123456 -filePath /data/deploy.yaml ``` > 启动时如果不指定filePath参数,则在请求接口时必须携带filePath参数 更新示例: ```bash curl -X POST 'http://127.0.0.1:5001/update-service' \ -H 'Authorization: Bearer 123456' \ -H 'Content-Type: application/json' \ -d '{ "image": "reg.abc.com:1880/front:17", "service": "volunteer-h5-front", "filePath": "/data/deploy.yaml" }' ``` 回滚示例 ```bash curl -X POST 'http://127.0.0.1:5001/rollback-service' \ -H 'Authorization: Bearer 123456' \ -H 'Content-Type: application/json' \ -d '{ "service": "nginx", "filePath": "/data/test/docker-compose.yml" }' ``` ### Systemd管理 ```shell # 添加执行权限 chmod +x compose_update_amd64_linux && mv compose_update_for_linux /usr/local/bin/compose_update # service文件 cat >/etc/systemd/system/compose_update.service <