feat(部署): 添加部署脚本用于启动和管理容器服务
This commit is contained in:
parent
30d64d4eb0
commit
daa920116b
|
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ENV=${1:-test}
|
||||||
|
IMAGE=${2:-marketingsystemdatatool_msdt:latest}
|
||||||
|
CMD=${3:-up}
|
||||||
|
|
||||||
|
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||||
|
|
||||||
|
if [ -f "$ROOT_DIR/.env.$ENV" ]; then
|
||||||
|
set -a
|
||||||
|
. "$ROOT_DIR/.env.$ENV"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$CMD" in
|
||||||
|
up)
|
||||||
|
docker rm -f msdt >/dev/null 2>&1 || true
|
||||||
|
docker run -d --name msdt \
|
||||||
|
-p 8077:8077 \
|
||||||
|
-e APP_ENV="$ENV" \
|
||||||
|
-e MARKETING_DB_HOST="${MARKETING_DB_HOST:-}" \
|
||||||
|
-e MARKETING_DB_PORT="${MARKETING_DB_PORT:-}" \
|
||||||
|
-e MARKETING_DB_USER="${MARKETING_DB_USER:-}" \
|
||||||
|
-e MARKETING_DB_PASSWORD="${MARKETING_DB_PASSWORD:-}" \
|
||||||
|
-e MARKETING_DB_NAME="${MARKETING_DB_NAME:-}" \
|
||||||
|
-e YMT_DB_HOST="${YMT_DB_HOST:-}" \
|
||||||
|
-e YMT_DB_PORT="${YMT_DB_PORT:-}" \
|
||||||
|
-e YMT_DB_USER="${YMT_DB_USER:-}" \
|
||||||
|
-e YMT_DB_PASSWORD="${YMT_DB_PASSWORD:-}" \
|
||||||
|
-e YMT_DB_NAME="${YMT_DB_NAME:-}" \
|
||||||
|
-v "$ROOT_DIR/server/storage:/app/storage" \
|
||||||
|
"$IMAGE" ;;
|
||||||
|
down)
|
||||||
|
docker rm -f msdt >/dev/null 2>&1 || true ;;
|
||||||
|
restart)
|
||||||
|
docker restart msdt ;;
|
||||||
|
logs)
|
||||||
|
docker logs -f msdt ;;
|
||||||
|
*)
|
||||||
|
echo "usage: deploy_image.sh <env> <image> [up|down|restart|logs]" >&2
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
Loading…
Reference in New Issue