添加服务器端发布脚本

This commit is contained in:
2026-01-17 07:14:41 +08:00
parent 215343166c
commit 1827f6ed3a
7 changed files with 137 additions and 0 deletions

2
.gitignore vendored
View File

@@ -2,4 +2,6 @@ bin/
logs/ logs/
runtime/ runtime/
reports/ reports/
target/
config.ini config.ini
*.log

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
# 基础镜像JDK11 轻量版
FROM openjdk:11-jre-slim
LABEL author="ZhanGSKen<zhangsken@qq.com>"
WORKDIR /sdcard/WinBoLLStudio/AuthCenterConsoleApp
# 关键修复:加./ 表示项目根目录的target避免路径找不到
COPY ./target/AuthCenter-1.0.0.jar authcenter.jar
# 暴露端口和你写的一致之前是8080现在改999了脚本也要同步
EXPOSE 999
# 启动命令(保留你的参数)
ENTRYPOINT ["java", "-Dfile.encoding=UTF-8", "-jar", "authcenter.jar", "-log:SEVERE"]

54
build-run-pro.sh Normal file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
set -e
# 核心配置(必改 CONFIG_DIR
APP_NAME="authcenter"
APP_VERSION="1.0.0"
IMAGE_NAME="${APP_NAME}:${APP_VERSION}"
CONTAINER_NAME="authcenter-app"
HOST_PORT=999
CONTAINER_PORT=990
CONFIG_DIR="/sdcard/WinBoLLStudio/AuthCenterConsoleApp" # 务必修改!例 /home/zhang/authcenter/config
WORK_DIR="/sdcard/WinBoLLStudio/AuthCenterConsoleApp"
log(){
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
}
log "===== 一键构建启动开始 ====="
# 1. Maven打包
log "1. Maven编译打包"
mvn clean package -Dmaven.test.skip=true
# 2. 删旧容器(强制)
log "2. 清理旧容器"
docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || log "无旧容器"
# 3. 删旧镜像
log "3. 清理旧镜像"
docker rmi -f "${IMAGE_NAME}" >/dev/null 2>&1 || log "无旧镜像"
# 清悬空镜像
docker rmi $(docker images -f dangling=true -q) 2>/dev/null || true
# 4. 构建镜像(变量加引号,必加!)
log "4. 构建镜像 ${IMAGE_NAME}"
docker build -t "${IMAGE_NAME}" .
# 5. 启动容器(挂载+时区+内存限制)
log "5. 启动容器"
docker run -d \
--name "${CONTAINER_NAME}" \
-p "${HOST_PORT}":"${CONTAINER_PORT}" \
-v "${CONFIG_DIR}":"${WORK_DIR}"/config:ro \
-v /etc/localtime:/etc/localtime:ro \
--restart=on-failure:3 \
--memory=512m \
"${IMAGE_NAME}"
# 验证
if docker ps | grep -w "${CONTAINER_NAME}"; then
log "✅ 成功!容器名:${CONTAINER_NAME} 访问http://本机IP:${HOST_PORT}"
else
log "❌ 容器启动失败!"
exit 1
fi

2
docker_build.sh Normal file
View File

@@ -0,0 +1,2 @@
# 构建镜像(标签为 authcenter:v1.0.0
docker build -t authcenter:v1.0.0 .

1
maven_build.sh Normal file
View File

@@ -0,0 +1 @@
mvn clean package -DskipTests

58
pom.xml Normal file
View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 基础配置按需修改groupId/artifactId/version -->
<groupId>cc.winboll</groupId>
<artifactId>AuthCenter</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>AuthCenter</name>
<description>AuthCenter 认证中心服务适配Android API30+JDK7</description>
<!-- 核心配置JDK7编译 + 依赖管理 -->
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<!-- JDK7 编译插件强制指定JDK版本避免环境冲突 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<bootclasspath>${java.home}/jre/lib/rt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<!-- 打包插件可选生成可执行jar排除无关依赖 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<!-- 按需指定主类,格式:包名.类名 -->
<mainClass>cc.winboll.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

6
run_docker.sh Normal file
View File

@@ -0,0 +1,6 @@
# 运行容器
docker run -d \
--name authcenter \
-p 999:999 \
-v /sdcard/WinBoLLStudio/AuthCenterConsoleApp:/sdcard/WinBoLLStudio/AuthCenterConsoleApp \
authcenter:v1.0.0