fusenapi/fs_package_docker_image.sh
laodaming 41949bef72 fix
2023-10-09 15:15:44 +08:00

24 lines
946 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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