fix(deploy): 修改默认环境为test并添加配置文件挂载支持
添加对config.$ENV_NAME.yaml配置文件的挂载支持,当文件存在时自动挂载到容器中 同时将默认部署环境从prod改为test,并优化错误提示信息
This commit is contained in:
parent
339fc18fdd
commit
48863be438
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
ENV_NAME="${1:-prod}"
|
ENV_NAME="${1:-test}"
|
||||||
IMAGE="marketing-system-data-tool"
|
IMAGE="marketing-system-data-tool"
|
||||||
TAG="$ENV_NAME"
|
TAG="$ENV_NAME"
|
||||||
PORT="${PORT:-8077}"
|
PORT="${PORT:-8077}"
|
||||||
|
|
@ -11,7 +11,7 @@ if [ ! -f "$ENV_FILE" ] && [ -f "server/.env.$ENV_NAME" ]; then
|
||||||
ENV_FILE="server/.env.$ENV_NAME"
|
ENV_FILE="server/.env.$ENV_NAME"
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$ENV_FILE" ]; then
|
if [ ! -f "$ENV_FILE" ]; then
|
||||||
echo "$ENV_FILE not found" >&2
|
echo "示例:server/.env.example" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
docker build -t "$IMAGE:$TAG" -f Dockerfile .
|
docker build -t "$IMAGE:$TAG" -f Dockerfile .
|
||||||
|
|
@ -24,6 +24,19 @@ fi
|
||||||
if docker ps -a --format '{{.Names}}' | grep -q "^${CID_NAME}$"; then
|
if docker ps -a --format '{{.Names}}' | grep -q "^${CID_NAME}$"; then
|
||||||
docker rm "$CID_NAME" >/dev/null 2>&1 || true
|
docker rm "$CID_NAME" >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
CONFIG_PATH="$ROOT_DIR/server/config.$ENV_NAME.yaml"
|
||||||
|
if [ -f "$CONFIG_PATH" ]; then
|
||||||
|
docker run -d \
|
||||||
|
--name "$CID_NAME" \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--env APP_ENV="$ENV_NAME" \
|
||||||
|
--env-file "$ENV_FILE" \
|
||||||
|
-p "$PORT:8077" \
|
||||||
|
-v "$ROOT_DIR/storage/export:/app/storage/export" \
|
||||||
|
-v "$ROOT_DIR/log:/app/log" \
|
||||||
|
-v "$CONFIG_PATH:/app/server/config.$ENV_NAME.yaml:ro" \
|
||||||
|
"$IMAGE:$TAG"
|
||||||
|
else
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name "$CID_NAME" \
|
--name "$CID_NAME" \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
|
|
@ -33,4 +46,5 @@ docker run -d \
|
||||||
-v "$ROOT_DIR/storage/export:/app/storage/export" \
|
-v "$ROOT_DIR/storage/export:/app/storage/export" \
|
||||||
-v "$ROOT_DIR/log:/app/log" \
|
-v "$ROOT_DIR/log:/app/log" \
|
||||||
"$IMAGE:$TAG"
|
"$IMAGE:$TAG"
|
||||||
|
fi
|
||||||
echo "container: $CID_NAME image: $IMAGE:$TAG port: $PORT"
|
echo "container: $CID_NAME image: $IMAGE:$TAG port: $PORT"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue