mirror of
https://github.com/yyhuni/xingrin.git
synced 2026-01-31 11:46:16 +08:00
chore: improve version detection and update deployment configuration
- Update version detection to support IMAGE_TAG environment variable for Docker containers - Add fallback mechanism to check multiple version file paths (/app/VERSION and project root) - Add IMAGE_TAG environment variable to docker-compose.dev.yml and docker-compose.yml - Fix frontend access URL in start.sh to include correct port (8083) - Update upgrade warning message in update.sh to recommend fresh installation with latest code - Improve robustness of version retrieval with better error handling for missing files
This commit is contained in:
@@ -23,11 +23,26 @@ GITHUB_RELEASES_URL = f"https://github.com/{GITHUB_REPO}/releases"
|
|||||||
|
|
||||||
def get_current_version() -> str:
|
def get_current_version() -> str:
|
||||||
"""读取当前版本号"""
|
"""读取当前版本号"""
|
||||||
version_file = Path(__file__).parent.parent.parent.parent.parent / 'VERSION'
|
import os
|
||||||
try:
|
|
||||||
return version_file.read_text(encoding='utf-8').strip()
|
# 方式1:从环境变量读取(Docker 容器中推荐)
|
||||||
except FileNotFoundError:
|
version = os.environ.get('IMAGE_TAG', '')
|
||||||
return "unknown"
|
if version:
|
||||||
|
return version
|
||||||
|
|
||||||
|
# 方式2:从文件读取(开发环境)
|
||||||
|
possible_paths = [
|
||||||
|
Path('/app/VERSION'),
|
||||||
|
Path(__file__).parent.parent.parent.parent.parent / 'VERSION',
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in possible_paths:
|
||||||
|
try:
|
||||||
|
return path.read_text(encoding='utf-8').strip()
|
||||||
|
except (FileNotFoundError, OSError):
|
||||||
|
continue
|
||||||
|
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
|
||||||
def compare_versions(current: str, latest: str) -> bool:
|
def compare_versions(current: str, latest: str) -> bool:
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
environment:
|
||||||
|
- IMAGE_TAG=${IMAGE_TAG:-dev}
|
||||||
ports:
|
ports:
|
||||||
- "8888:8888"
|
- "8888:8888"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
environment:
|
||||||
|
- IMAGE_TAG=${IMAGE_TAG}
|
||||||
depends_on:
|
depends_on:
|
||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ echo -e "${BOLD}${GREEN}══════════════════
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "${BOLD}访问地址${NC}"
|
echo -e "${BOLD}访问地址${NC}"
|
||||||
if [ "$WITH_FRONTEND" = true ]; then
|
if [ "$WITH_FRONTEND" = true ]; then
|
||||||
echo -e " XingRin: ${CYAN}https://${ACCESS_HOST}/${NC}"
|
echo -e " XingRin: ${CYAN}https://${ACCESS_HOST}:8083/${NC}"
|
||||||
echo -e " ${YELLOW}(HTTP 会自动跳转到 HTTPS)${NC}"
|
echo -e " ${YELLOW}(HTTP 会自动跳转到 HTTPS)${NC}"
|
||||||
else
|
else
|
||||||
echo -e " API: ${CYAN}通过前端或 nginx 访问(后端未暴露 8888)${NC}"
|
echo -e " API: ${CYAN}通过前端或 nginx 访问(后端未暴露 8888)${NC}"
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ echo ""
|
|||||||
|
|
||||||
# 测试性功能警告
|
# 测试性功能警告
|
||||||
echo -e "${BOLD}${YELLOW}[!] 警告:此功能为测试性功能,可能会导致升级失败${NC}"
|
echo -e "${BOLD}${YELLOW}[!] 警告:此功能为测试性功能,可能会导致升级失败${NC}"
|
||||||
echo -e "${YELLOW} 建议运行 ./uninstall.sh 后重新执行 ./install.sh 进行全新安装${NC}"
|
echo -e "${YELLOW} 建议运行 ./uninstall.sh 后重新clone最新代码进行全新安装${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -n -e "${YELLOW}是否继续更新?(y/N) ${NC}"
|
echo -n -e "${YELLOW}是否继续更新?(y/N) ${NC}"
|
||||||
read -r ans_continue
|
read -r ans_continue
|
||||||
|
|||||||
Reference in New Issue
Block a user