添加部署命令

This commit is contained in:
Rzy 2024-07-16 18:39:48 +08:00
parent 9153e1de6e
commit 93d95254b7
9 changed files with 43 additions and 38 deletions

View File

@ -12,7 +12,7 @@ import (
"trasfer_middleware/until/sysLog"
)
var configFile = flag.String("f", "../../../config/transfer_local.yaml", "the config file")
var configFile = flag.String("f", "../../../config/transfer_produce.yaml", "the config file")
func main() {
flag.Parse()

View File

@ -16,9 +16,10 @@ import (
"trasfer_middleware/cmd/rpc/internal/server"
"trasfer_middleware/cmd/rpc/internal/svc"
"trasfer_middleware/cmd/rpc/pb/transfer"
"trasfer_middleware/until"
)
var configFile = flag.String("f", "../../config/transfer_local.yaml", "the config file")
var configFile = flag.String("f", until.GetConfig(), "the config file")
func main() {
flag.Parse()

View File

@ -1,9 +1,7 @@
#!/bin/bash
source ./config.sh
docker build -t "${IMAGE}:${VERSION}" . --no-cache
docker tag "${IMAGE}:${TAGS_NAME}" ${ADDRESS}:${TAGS_NAME}
docker tag "${IMAGE}:${VERSION}" ${ADDRESS}:${VERSION}
docker push ${ADDRESS}:${TAGS_NAME}
docker push ${ADDRESS}:${VERSION}

View File

@ -1,14 +1,9 @@
#!/bin/bash
IMAGE="transfer_middleware"
RPC_CONTAINER="transfer_middleware"
RPC_PORT="10001"
V_REFLECT=""
TAGS_NAME="v1"
ADDRESS="registry.cn-chengdu.aliyuncs.com/go_ls/transfer_middleware"
. $(pwd)/sh/config.sh
Environment="produce"
ADDRESS="${PRODUCE_ADDRESS}"
echo "produce"> $(pwd)/sh/env
docker build -t "${IMAGE}:${TAGS_NAME}" . --no-cache
. $(pwd)/sh/build.sh
docker tag "${IMAGE}:${TAGS_NAME}" ${ADDRESS}:${TAGS_NAME}
docker push ${ADDRESS}:${TAGS_NAME}

View File

@ -1,14 +1,7 @@
#!/bin/bash
IMAGE="transfer_middleware"
RPC_CONTAINER="transfer_middleware"
RPC_PORT="10001"
V_REFLECT=""
TAGS_NAME="v1"
ADDRESS="registry.cn-chengdu.aliyuncs.com/go_ls/transfer_middleware"
docker build -t "${IMAGE}:${TAGS_NAME}" . --no-cache
docker tag "${IMAGE}:${TAGS_NAME}" ${ADDRESS}:${TAGS_NAME}
docker push ${ADDRESS}:${TAGS_NAME}
. $(pwd)/sh/config.sh
Environment="test"
ADDRESS="${TEST_ADDRESS}"
echo "test"> $(pwd)/sh/env
sh $(pwd)/sh/build.sh

View File

@ -0,0 +1,7 @@
IMAGE="transfer_middleware"
CONTAINER="transfer_middleware"
PORT="10001"
TEST_ADDRESS="registry.cn-chengdu.aliyuncs.com/go_ls/transfer_middleware"
PRODUCE_ADDRESS="registry.cn-chengdu.aliyuncs.com/go_ls/transfer_middleware_produce"
COMMIT_CONTENT="UPDATE"
VERSION="v1"

View File

@ -1,14 +1,17 @@
#!/bin/bash
IMAGE="transfer_middleware:v1"
RPC_CONTAINER="transfer_middleware"
RPC_PORT="10001"
V_REFLECT=""
. $(pwd)/sh/config.sh
ENV=$(cat "$(pwd)/sh/env")
# 使用if-elif-else结构判断环境
if [ "$ENV"=="produce" ]; then
ADDRESS="${PRODUCE_ADDRESS}"
elif [ "$ENV"=="test" ]; then
ADDRESS="${TEST_ADDRESS}"
else
ADDRESS="${PRODUCE_ADDRESS}"
fi
docker build -t "${IMAGE}" . --no-cache
docker stop "${RPC_CONTAINER}"
docker rm "${RPC_CONTAINER}"
#docker run -it -p "${RPC_PORT}:${RPC_PORT}" --name "$RPC_CONTAINER" "${IMAGE}"
docker pull ${ADDRESS}:${VERSION}
docker rm -f "${CONTAINER}"
docker run -it -p "${PORT}:${PORT}" --name "${CONTAINER}" "${IMAGE}:${VERSION}"

1
sh/env Normal file
View File

@ -0,0 +1 @@
produce

View File

@ -1 +1,8 @@
package until
import "os"
func GetConfig() string {
return os.Getenv("GO_ENV")
}