Compare commits
No commits in common. "455859dab6bf4e1ed22214be18f9c20db18ad301" and "48863be438f060bdc1272eb8b40454a0fd5fa9f6" have entirely different histories.
455859dab6
...
48863be438
|
|
@ -1,28 +1,18 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
ENV_NAME="${1:-test}"
|
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}"
|
||||||
cd "$ROOT_DIR"
|
cd "$ROOT_DIR"
|
||||||
ENV_FILE_OVERRIDE="${2:-}"
|
ENV_FILE=".env.$ENV_NAME"
|
||||||
ENV_FILE=""
|
if [ ! -f "$ENV_FILE" ] && [ -f "server/.env.$ENV_NAME" ]; then
|
||||||
if [ -n "$ENV_FILE_OVERRIDE" ]; then
|
|
||||||
if [ -f "$ENV_FILE_OVERRIDE" ]; then
|
|
||||||
ENV_FILE="$ENV_FILE_OVERRIDE"
|
|
||||||
else
|
|
||||||
echo "警告:指定的 env 文件不存在:$ENV_FILE_OVERRIDE,忽略 --env-file" >&2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -f ".env.$ENV_NAME" ]; then
|
|
||||||
ENV_FILE=".env.$ENV_NAME"
|
|
||||||
elif [ -f "server/.env.$ENV_NAME" ]; then
|
|
||||||
ENV_FILE="server/.env.$ENV_NAME"
|
ENV_FILE="server/.env.$ENV_NAME"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$ENV_FILE" ]; then
|
if [ ! -f "$ENV_FILE" ]; then
|
||||||
echo "未使用 env 文件,配置仅通过 server/config.$ENV_NAME.yaml 加载" >&2
|
echo "示例:server/.env.example" >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
docker build -t "$IMAGE:$TAG" -f Dockerfile .
|
docker build -t "$IMAGE:$TAG" -f Dockerfile .
|
||||||
mkdir -p log storage/export
|
mkdir -p log storage/export
|
||||||
|
|
@ -35,11 +25,7 @@ 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"
|
CONFIG_PATH="$ROOT_DIR/server/config.$ENV_NAME.yaml"
|
||||||
if [ ! -f "$CONFIG_PATH" ]; then
|
if [ -f "$CONFIG_PATH" ]; then
|
||||||
echo "配置文件缺失:$CONFIG_PATH" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -n "$ENV_FILE" ]; then
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name "$CID_NAME" \
|
--name "$CID_NAME" \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
|
|
@ -55,10 +41,10 @@ else
|
||||||
--name "$CID_NAME" \
|
--name "$CID_NAME" \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
--env APP_ENV="$ENV_NAME" \
|
--env APP_ENV="$ENV_NAME" \
|
||||||
|
--env-file "$ENV_FILE" \
|
||||||
-p "$PORT:8077" \
|
-p "$PORT:8077" \
|
||||||
-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" \
|
||||||
-v "$CONFIG_PATH:/app/server/config.$ENV_NAME.yaml:ro" \
|
|
||||||
"$IMAGE:$TAG"
|
"$IMAGE:$TAG"
|
||||||
fi
|
fi
|
||||||
echo "container: $CID_NAME image: $IMAGE:$TAG port: $PORT"
|
echo "container: $CID_NAME image: $IMAGE:$TAG port: $PORT"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue