From 1c572e9c8df67b24cafa5ecfcf86a4a045d43be6 Mon Sep 17 00:00:00 2001 From: whz <303054730@qq.com> Date: Tue, 4 Jun 2024 08:28:50 +0800 Subject: [PATCH 1/4] fix --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ae08307..f44d4de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN gradle bootJar # 使用官方的Java运行时作为最终的运行环境 FROM openjdk:17-jdk-slim WORKDIR /app -COPY --from=build/libs /app/build/libs/*.jar app.jar +COPY --from=build /app/build/libs/*.jar app.jar # 设置应用运行的端口 EXPOSE 8080 From 8cddc05cbf0563fba74161e841dbfc18263a60c2 Mon Sep 17 00:00:00 2001 From: whz <303054730@qq.com> Date: Tue, 4 Jun 2024 08:31:29 +0800 Subject: [PATCH 2/4] fix --- docker-compose.yml | 2 +- src/main/resources/application-prod.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cd2ea84..91e1efb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: restart: always environment: MYSQL_ROOT_PASSWORD: example - MYSQL_DATABASE: mydb + MYSQL_DATABASE: paopao MYSQL_USER: myuser MYSQL_PASSWORD: mypassword volumes: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 15ab256..d51f950 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -8,8 +8,8 @@ spring: datasource: url: jdbc:mysql://db:3306/paopao?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true # MySQL连接URL,paopao是数据库名 driverClassName: com.mysql.cj.jdbc.Driver # MySQL的Driver类名 - username: root # MySQL用户名 - password: root # MySQL密码 + username: myuser # MySQL用户名 + password: mypassword # MySQL密码 jpa: show-sql: true From 443bdd7820c07fd264959b01f70a9faf4f87958b Mon Sep 17 00:00:00 2001 From: whz <303054730@qq.com> Date: Tue, 4 Jun 2024 08:58:29 +0800 Subject: [PATCH 3/4] fix --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f44d4de..028ba31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,13 +3,11 @@ WORKDIR /app # 将Gradle的配置文件复制到镜像中 COPY gradlew . -COPY gradle gradle COPY build.gradle . COPY settings.gradle . - COPY src src # 构建应用 -RUN gradle bootJar +RUN ./gradlew bootJar # 使用官方的Java运行时作为最终的运行环境 FROM openjdk:17-jdk-slim From c83a477c7a06dd81b585e6b51e7970d14b7ebc77 Mon Sep 17 00:00:00 2001 From: whz <303054730@qq.com> Date: Tue, 4 Jun 2024 09:00:34 +0800 Subject: [PATCH 4/4] fix --- docs/guides/spring-boot-docker.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/spring-boot-docker.md b/docs/guides/spring-boot-docker.md index 5e76179..868a458 100644 --- a/docs/guides/spring-boot-docker.md +++ b/docs/guides/spring-boot-docker.md @@ -11,13 +11,12 @@ WORKDIR /app # 将Gradle的配置文件复制到镜像中 COPY gradlew . -COPY gradle gradle COPY build.gradle . COPY settings.gradle . COPY src src # 构建应用 -RUN gradle bootJar +RUN /app/gradlew bootJar # 使用官方的Java运行时作为最终的运行环境 FROM openjdk:17-jdk-slim @@ -75,7 +74,8 @@ services: - "8080:8080" depends_on: - db - + environment: + - SPRING_PROFILES_ACTIVE=prod volumes: dbdata: ```