fusenapi/fs_package_docker_image.sh

24 lines
946 B
Bash
Raw Normal View History

2023-08-03 08:49:25 +00:00
#!/bin/bash
name=${1%%\\*}
#进入对应服务目录
cd server/$name
2023-10-09 07:15:44 +00:00
#把https加密密钥对复制进来
cp /opt/env.yaml ./
cp /opt/server.fusen.3718.cn.pem ./
cp /opt/server.fusen.3718.cn.key ./
2023-08-03 08:49:25 +00:00
#构建二进制文件
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-10-09 07:15:44 +00:00
#删除临时复制进来的文件
rm ./env.yaml
rm ./server.fusen.3718.cn.pem
rm ./server.fusen.3718.cn.key
2023-08-04 08:09:05 +00:00
#打tag(测试环境正式把命名空间fusentest改成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 08:09:05 +00:00
#推送到阿里云镜像库(测试环境正式把命名空间fusentest改成fusen)
2023-08-04 05:25:51 +00:00
docker push registry.cn-hangzhou.aliyuncs.com/fusen-test/$name:latest