fusenapi/fs_package_docker_image.sh
laodaming e00c813e72 fix
2023-08-03 17:49:17 +08:00

14 lines
706 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
#构建二进制文件
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镜像
docker build -t api-$name-srv:latest .
#把本地镜像load到k8s中(这个适用于无dockerhub镜像仓库情况,需要对应的deployment中的 imagePullPolicy 参数从 Always 变成None)
minikube image load api-$name-srv:latest
#上传镜像到dockerhub(有dockerhub镜像仓库后打开且把上面的load image去掉对应的deployment中的 imagePullPolicy 参数从 None 改为 Always)
#docker push api-$name-srv:latest