From d009899565519500b3966d779b581605ed90c74e Mon Sep 17 00:00:00 2001
From: ChuXun <70203584+ChuXunYu@users.noreply.github.com>
Date: Thu, 29 Jan 2026 06:13:01 +0800
Subject: [PATCH] 1
---
.dockerignore | 7 +++++
.env.example | 5 ++++
.idea/.gitignore | 10 -------
.idea/AugmentWebviewStateStore.xml | 10 -------
.idea/dataSources.xml | 32 -----------------------
.idea/encodings.xml | 7 -----
.idea/misc.xml | 14 ----------
.idea/vcs.xml | 6 -----
Dockerfile | 25 ++++++++++++++++++
docker-compose.yml | 9 +++++++
src/main/resources/application.properties | 8 +++---
11 files changed, 50 insertions(+), 83 deletions(-)
create mode 100644 .dockerignore
create mode 100644 .env.example
delete mode 100644 .idea/.gitignore
delete mode 100644 .idea/AugmentWebviewStateStore.xml
delete mode 100644 .idea/dataSources.xml
delete mode 100644 .idea/encodings.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/vcs.xml
create mode 100644 Dockerfile
create mode 100644 docker-compose.yml
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..ac877a5
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,7 @@
+.git
+target/
+*.log
+*.iml
+.idea/
+.vscode/
+gpa_system_backup.sql
diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..94e7a85
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,5 @@
+SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/gpa_system?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
+SPRING_DATASOURCE_USERNAME=root
+SPRING_DATASOURCE_PASSWORD=root
+SERVER_PORT=8080
+JAVA_OPTS=
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 7d05e99..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-# 默认忽略的文件
-/shelf/
-/workspace.xml
-# 基于编辑器的 HTTP 客户端请求
-/httpRequests/
-# 依赖于环境的 Maven 主目录路径
-/mavenHomeManager.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/AugmentWebviewStateStore.xml b/.idea/AugmentWebviewStateStore.xml
deleted file mode 100644
index 0d550ff..0000000
--- a/.idea/AugmentWebviewStateStore.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
deleted file mode 100644
index 11a3db9..0000000
--- a/.idea/dataSources.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- mysql.8
- true
- com.mysql.cj.jdbc.Driver
- jdbc:mysql://localhost:3306
-
-
-
-
-
-
- $ProjectFileDir$
-
-
- mysql.8
- true
- true
- $PROJECT_DIR$/src/main/resources/application.properties
- com.mysql.cj.jdbc.Driver
- jdbc:mysql://localhost:3306/gpa_system?useSSL=false&serverTimezone=UTC
-
-
-
-
-
- $ProjectFileDir$
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index aa00ffa..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 82dbec8..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..ba57bae
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,25 @@
+FROM maven:3.9.6-eclipse-temurin-17 AS build
+
+WORKDIR /app
+
+COPY pom.xml /app/
+COPY src /app/src
+
+RUN mvn -B -DskipTests package \
+ && ls -1 target/*.jar | grep -v "original" | head -n 1 | xargs -I{} cp {} /app/app.jar
+
+FROM eclipse-temurin:17-jre-jammy
+
+WORKDIR /app
+
+RUN useradd --create-home --shell /usr/sbin/nologin appuser
+
+COPY --from=build /app/app.jar /app/app.jar
+
+USER appuser
+
+ENV JAVA_OPTS=""
+
+EXPOSE 8080
+
+ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..a02c8f9
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,9 @@
+services:
+ gpa-found-data:
+ build: .
+ image: docker.aizhangz.top/admin/gpa_found_data:latest
+ restart: unless-stopped
+ env_file:
+ - .env
+ ports:
+ - "8080:8080"
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e35fc88..7023d4f 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,7 +1,7 @@
-spring.datasource.url=jdbc:mysql://localhost:3306/gpa_system?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
-spring.datasource.username=root
-spring.datasource.password=root
+spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:mysql://localhost:3306/gpa_system?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true}
+spring.datasource.username=${SPRING_DATASOURCE_USERNAME:root}
+spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:root}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
@@ -9,4 +9,4 @@ spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.format_sql=true
-server.port=8080
\ No newline at end of file
+server.port=${SERVER_PORT:8080}