From 30d64d4eb024267a83d5803a04e1a99b863f6ddc Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Fri, 28 Nov 2025 15:58:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(scripts):=20=E5=A2=9E=E5=BC=BA=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=A8=A1=E5=BC=8F=E5=92=8C=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对多种构建模式的支持,包括不构建、重新构建、拉取最新镜像等 默认环境从prod改为test,并支持根据环境加载对应的.env文件 --- scripts/deploy.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 294bf6e..cb2730b 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,4 +1,18 @@ #!/usr/bin/env sh set -e -ENV=${1:-prod} -APP_ENV=$ENV docker compose up -d --build +ENV=${1:-test} +MODE=${2:-no-build} +ENVFILE="" +if [ -f ".env.$ENV" ]; then ENVFILE="--env-file .env.$ENV"; fi +case "$MODE" in + no-build) + APP_ENV=$ENV docker compose $ENVFILE up -d ;; + rebuild) + APP_ENV=$ENV docker compose $ENVFILE build --no-cache + APP_ENV=$ENV docker compose $ENVFILE up -d ;; + pull) + APP_ENV=$ENV docker compose $ENVFILE build --pull + APP_ENV=$ENV docker compose $ENVFILE up -d ;; + build|*) + APP_ENV=$ENV docker compose $ENVFILE up -d --build ;; +esac