diff --git a/init_deploy.sh b/init_deploy.sh index d311533..327cfb3 100644 --- a/init_deploy.sh +++ b/init_deploy.sh @@ -3,7 +3,7 @@ # 初始化部署脚本 - 在云端服务器上生成部署文件并拉取代码 # 部署目录 -deploy_dir="/opt/project_root" +deploy_dir="/opt/project_user" mkdir -p "$deploy_dir" cd "$deploy_dir" @@ -21,8 +21,8 @@ LABEL maintainer="your-email@example.com" # 删除Tomcat默认的ROOT应用 RUN rm -rf /usr/local/tomcat/webapps/ROOT -# 将构建好的WAR文件复制到Tomcat的webapps目录下,并命名为backend.war,与配置文件中的上下文路径一致 -COPY web.war /usr/local/tomcat/webapps/backend.war +# 将构建好的WAR文件复制到Tomcat的webapps目录下,并命名为DL.war,与配置文件中的上下文路径一致 +COPY web.war /usr/local/tomcat/webapps/DL.war # 暴露Tomcat默认端口 EXPOSE 8080 @@ -36,7 +36,7 @@ echo "创建docker-compose.yml..." cat > docker-compose.yml << 'EOF' services: tomcat-app: - image: web-application:latest + image: web:latest ports: - "8080:8080" environment: @@ -46,9 +46,9 @@ services: - SPRING_DATASOURCE_WECHAT_JDBC_URL=jdbc:mysql://1.95.162.61:3306/wechat_app?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true - SPRING_DATASOURCE_WECHAT_USERNAME=root - SPRING_DATASOURCE_WECHAT_PASSWORD=schl@2025 - - SERVER_SERVLET_CONTEXT_PATH=/backend + - SERVER_SERVLET_CONTEXT_PATH=/DL restart: always - container_name: web-application + container_name: web EOF # 3. 创建deploy.sh @@ -59,11 +59,11 @@ cat > deploy.sh << 'EOF' # 修复后的部署脚本 - 解决Maven构建找不到pom.xml的问题 # 配置信息 -GIT_REPO="http://8.137.125.67:4000/SwtTt29/Page--root.git" +GIT_REPO="http://8.137.125.67:4000/SwtTt29/Page--user.git" BRANCH="master" PROJECT_NAME="web" -DOCKER_IMAGE="web-application" -CONTAINER_NAME="web-application" +DOCKER_IMAGE="web" +CONTAINER_NAME="web" PORT="8080" # 颜色定义 @@ -149,8 +149,8 @@ if [[ "$war_path" != /* ]]; then war_path="$(pwd)/$war_path" fi -# 9. 返回项目根目录(当前在maven_dir,需要返回到/opt/project_root目录) -cd /opt/project_root +# 9. 返回项目根目录(当前在maven_dir,需要返回到/opt/project_user目录) +cd /opt/project_user # 9. 复制WAR文件到web子目录下,供Dockerfile使用 cp "$war_path" ./web/web.war @@ -158,7 +158,7 @@ cp "$war_path" ./web/web.war echo -e "${GREEN}4. 停止并移除旧容器...${NC}" # 确保旧容器被完全移除,即使docker-compose down失败 -old_container=$(docker ps -a -q -f name=web-application) +old_container=$(docker ps -a -q -f name=web) if [ ! -z "$old_container" ]; then echo -e "${GREEN} 停止旧容器...${NC}" docker stop "$old_container" > /dev/null 2>&1 @@ -171,7 +171,7 @@ docker-compose down 2>/dev/null || true # 10. 构建新的Docker镜像 echo -e "${GREEN}5. 构建Docker镜像...${NC}" -docker build -t web-application:latest ./web +docker build -t web:latest ./web if [ $? -ne 0 ]; then echo -e "${RED}错误: Docker构建失败${NC}" exit 1 @@ -189,7 +189,7 @@ fi rm -f ./web/web.war echo -e "${GREEN}部署完成!${NC}" -echo -e "${YELLOW}应用访问地址: http://8.137.125.67:${PORT}/backend${NC}" +echo -e "${YELLOW}应用访问地址: http://8.137.125.67:${PORT}/DL${NC}" echo -e "${YELLOW}容器名称: ${CONTAINER_NAME}${NC}" echo -e "${YELLOW}查看日志命令: docker logs -f ${CONTAINER_NAME}${NC}" EOF @@ -200,7 +200,7 @@ chmod +x deploy.sh # 5. 拉取Git代码 echo "拉取Git代码..." -git clone http://8.137.125.67:4000/SwtTt29/Page--root.git web +git clone http://8.137.125.67:4000/SwtTt29/Page--user.git web # 6. 将Dockerfile复制到web目录 cp Dockerfile web/ diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 00eda00..4f96ade 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -63,7 +63,7 @@ management: enabled: true server: - port: 8081 + port: 8080 servlet: context-path: /DL encoding: diff --git a/src/main/resources/static/loginmm.html b/src/main/resources/static/loginmm.html index f496a49..136fccf 100644 --- a/src/main/resources/static/loginmm.html +++ b/src/main/resources/static/loginmm.html @@ -520,7 +520,7 @@ errorElement.classList.remove('show'); } - const API_BASE_URL = 'http://localhost:8081/DL'; // 服务器API地址 + const API_BASE_URL = 'http://8.137.125.67:8080/DL'; // 服务器API地址 async function sendLoginRequest(projectName, userName, password) { try { // 使用URL编码的表单数据 diff --git a/src/main/resources/static/sells.html b/src/main/resources/static/sells.html index 9e3b476..d2ab632 100644 --- a/src/main/resources/static/sells.html +++ b/src/main/resources/static/sells.html @@ -4727,7 +4727,7 @@ return currentPageRecords; } - const API_BASE_URL = 'http://localhost:8081/DL'; // 后端API基础地址 + const API_BASE_URL = 'http://8.137.125.67:8080/DL'; // 后端API基础地址 // 获取登录用户信息函数 function getLoginUserInfo() { diff --git a/src/main/resources/static/supply.html b/src/main/resources/static/supply.html index 1903926..fe9c785 100644 --- a/src/main/resources/static/supply.html +++ b/src/main/resources/static/supply.html @@ -4781,7 +4781,7 @@ return currentPageRecords; } - const API_BASE_URL = 'http://localhost:8081/DL'; // 后端API基础地址 + const API_BASE_URL = 'http://8.137.125.67:8080/DL'; // 后端API基础地址 // 获取登录用户信息函数 function getLoginInfo() {