add nginx configuration to Dockerfile
Change-Id: Ib5617f589956a7bb778335416ae7d69f11d486ae
diff --git a/.gitignore b/.gitignore
index a0134b4..a135372 100644
--- a/.gitignore
+++ b/.gitignore
@@ -165,3 +165,4 @@
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
+/upload
diff --git a/Dockerfile b/Dockerfile
index 0738188..6b47fed 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,11 +5,24 @@
COPY . .
RUN mvn clean package -DskipTests
-# Step 2: 运行 jar
-FROM eclipse-temurin:21-jdk
+FROM nginx:alpine
+# 创建运行目录
WORKDIR /app
+
+# 拷贝 jar 到运行目录
COPY --from=builder /app/target/*.jar app.jar
+RUN mkdir /app/upload/
+
+# 拷贝 Nginx 配置文件
+COPY nginx.conf /etc/nginx/nginx.conf
+
+# 安装 OpenJDK 运行环境
+RUN apk add --no-cache openjdk21-jdk curl
+
+# 后台启动 Spring Boot + 前台运行 Nginx
+EXPOSE 8082
EXPOSE 8080
-ENTRYPOINT ["java", "-jar", "app.jar"]
+
+CMD java -jar app.jar & nginx -g "daemon off;"
diff --git a/nginx.conf b/nginx.conf
new file mode 100644
index 0000000..dd6cedc
--- /dev/null
+++ b/nginx.conf
@@ -0,0 +1,20 @@
+worker_processes 1;
+events { worker_connections 1024; }
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ sendfile on;
+ keepalive_timeout 65;
+
+ server {
+ listen 8082;
+
+ # 1. 代理静态资源:如 http://localhost/static/index.html
+ location /upload/ {
+ alias /app/upload/;
+ autoindex on;
+ }
+ }
+}