fix: deploy.sh uses PORT from .env exclusively, remove CLI port argument
This commit is contained in:
@@ -81,10 +81,8 @@ setup_go_proxy() {
|
||||
# 4. 读取 .env 配置文件
|
||||
# ----------------------------------------------------------
|
||||
load_env() {
|
||||
local port="${1:-9050}"
|
||||
|
||||
if [ ! -f ".env" ]; then
|
||||
error ".env 文件不存在,请先执行: cp .env.example .env 并填写 MySQL 连接信息"
|
||||
error ".env 文件不存在,请先执行: cp .env.example .env 并填写配置"
|
||||
fi
|
||||
|
||||
info "读取 .env 配置..."
|
||||
@@ -93,11 +91,10 @@ load_env() {
|
||||
source .env
|
||||
set +a
|
||||
|
||||
# 命令行参数覆盖 .env 中的 PORT
|
||||
if [ -n "$port" ]; then
|
||||
export PORT="$port"
|
||||
fi
|
||||
# 端口默认值
|
||||
export PORT="${PORT:-8080}"
|
||||
|
||||
info "服务端口: ${PORT}"
|
||||
info "MySQL: ${MYSQL_USER}@${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}"
|
||||
}
|
||||
|
||||
@@ -105,8 +102,6 @@ load_env() {
|
||||
# 5. 构建并启动服务
|
||||
# ----------------------------------------------------------
|
||||
build_and_start() {
|
||||
local port="${1:-9050}"
|
||||
|
||||
info "构建 Docker 镜像(首次可能需要几分钟)..."
|
||||
docker compose build
|
||||
|
||||
@@ -136,10 +131,8 @@ build_and_start() {
|
||||
info "=========================================="
|
||||
info " PR-Helper 部署成功!"
|
||||
info "=========================================="
|
||||
info "访问地址: http://$(hostname -I | awk '{print $1}'):${port}"
|
||||
info "本地访问: http://localhost:${port}"
|
||||
info ""
|
||||
info "数据库配置: .env"
|
||||
info "访问地址: http://$(hostname -I | awk '{print $1}'):${PORT}"
|
||||
info "本地访问: http://localhost:${PORT}"
|
||||
info ""
|
||||
info "常用命令:"
|
||||
info " 查看日志: docker compose logs -f"
|
||||
@@ -155,16 +148,13 @@ build_and_start() {
|
||||
# 主流程
|
||||
# ----------------------------------------------------------
|
||||
main() {
|
||||
local port="${1:-9050}"
|
||||
|
||||
info "开始部署 PR-Helper..."
|
||||
info "目标端口: ${port}"
|
||||
|
||||
check_docker
|
||||
setup_docker_mirror
|
||||
setup_go_proxy
|
||||
load_env "$port"
|
||||
build_and_start "$port"
|
||||
load_env
|
||||
build_and_start
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user