fusenapi/fs_package_docker_image.sh

16 lines
710 B
Bash
Raw Normal View History

2023-08-03 08:49:25 +00:00
#!/bin/bash
name=${1%%\\*}
#进入对应服务目录
cd server/$name
#构建二进制文件
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api-$name-srv ./$name.go
#删除之前旧的镜像
docker rmi -f api-$name-srv:latest
2023-08-04 05:25:51 +00:00
docker rmi -f registry.cn-hangzhou.aliyuncs.com/fusen-test/fusen_docker_hub:latest
2023-08-03 08:49:25 +00:00
#打包docker镜像
docker build -t api-$name-srv:latest .
2023-08-04 05:25:51 +00:00
#打tag(测试环境正式把命名空间fusen-test改成fusen)
2023-08-04 04:21:30 +00:00
docker tag api-$name-srv:latest registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest
2023-08-04 05:25:51 +00:00
#推送到阿里云镜像库(测试环境正式把命名空间fusen-test改成fusen)
docker push registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest