From 546564db1fd4061edc72870e5f135f1db478019c Mon Sep 17 00:00:00 2001 From: wuwendi <646907729@qq.com> Date: Thu, 17 Nov 2022 17:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=97=E5=90=91=E7=9C=8B=E6=9D=BF=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1-=E7=BC=96=E8=AF=91=E9=83=A8=E7=BD=B2-=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=BC=96=E8=AF=91=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/southbound/docker-compose.yaml | 6 ++-- .../southbound-service/DockerAppFile | 1 + .../southbound/southbound-service/Dockerfile | 31 ++++++++++++++++++- tools/southbound/southbound-service/pom.xml | 11 ------- .../southbound/SouthBoundApplication.java | 3 -- .../main/resources/application-dev.properties | 12 ++----- .../resources/application-prod.properties | 11 +++---- 7 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 tools/southbound/southbound-service/DockerAppFile diff --git a/tools/southbound/docker-compose.yaml b/tools/southbound/docker-compose.yaml index 2483327..d5d23a5 100644 --- a/tools/southbound/docker-compose.yaml +++ b/tools/southbound/docker-compose.yaml @@ -46,7 +46,7 @@ services: app: container_name: southbound-server - build: ./southbound-service + build: ./southbound-service/DockerAppFile restart: always #设置工作目录为容器内的app文件夹 working_dir: /app @@ -60,8 +60,8 @@ services: # 先启动 depends_on 下面的服务后,再启动本服务。依赖于nginx,mysql容器,被依赖容器启动后app容器才启动。 depends_on: - nginx - #- mysql + - mysql # 使用该命令启动项目,使用 application-prod.properties配置文件 command: bash -c "mvn clean package -Dfile.encoding=UTF-8 -DskipTests=true - && java -Djasypt.encryptor.password=sla -jar /app/target/SouthboundDashBoard-0.0.1-SNAPSHOT.jar" + && java -jar /app/target/SouthboundDashBoard-0.0.1-SNAPSHOT.jar" diff --git a/tools/southbound/southbound-service/DockerAppFile b/tools/southbound/southbound-service/DockerAppFile new file mode 100644 index 0000000..97ad5f4 --- /dev/null +++ b/tools/southbound/southbound-service/DockerAppFile @@ -0,0 +1 @@ +FROM maven:3.6-jdk-8 \ No newline at end of file diff --git a/tools/southbound/southbound-service/Dockerfile b/tools/southbound/southbound-service/Dockerfile index 97ad5f4..5bc2fcd 100644 --- a/tools/southbound/southbound-service/Dockerfile +++ b/tools/southbound/southbound-service/Dockerfile @@ -1 +1,30 @@ -FROM maven:3.6-jdk-8 \ No newline at end of file +# AS builder 起别名 +FROM maven:3.6.3-openjdk-8 AS builder +# 创建临时文件 +RUN mkdir /build +# 将src目录复制到临时目录 +ADD src /build/src +# 将pom文件复制到临时目录 +ADD pom.xml /build + +# 设置变量 +ENV username="" +ENV password="" +ENV url="" +# 打包 +RUN cd /build && mvn -B -ntp package -DskipTests + +# 获取jre +FROM openjdk:8-jre-alpine + +# 解决时区问题、修改容器的时区为东八区 +ENV TZ Asia/Shanghai + +# 公开端口 +EXPOSE 8099 + +# 从标记点 拷贝jar包 并改名 +COPY --from=builder /build/target/SouthboundDashBoard-0.0.1-SNAPSHOT.jar /app.jar + +#设置启动命令 +ENTRYPOINT ["sh","-c","java -jar /app.jar --spring.datasource.username=$username --spring.datasource.url=$url --spring.datasource.password=$password"] \ No newline at end of file diff --git a/tools/southbound/southbound-service/pom.xml b/tools/southbound/southbound-service/pom.xml index a255770..02e3a40 100644 --- a/tools/southbound/southbound-service/pom.xml +++ b/tools/southbound/southbound-service/pom.xml @@ -88,17 +88,6 @@ poi-ooxml 4.0.1 - - - com.github.ulisesbocchio - jasypt-spring-boot-starter - 3.0.4 - - - org.jasypt - jasypt - 1.9.3 - diff --git a/tools/southbound/southbound-service/src/main/java/com/openeuler/southbound/SouthBoundApplication.java b/tools/southbound/southbound-service/src/main/java/com/openeuler/southbound/SouthBoundApplication.java index 68b118c..8940679 100644 --- a/tools/southbound/southbound-service/src/main/java/com/openeuler/southbound/SouthBoundApplication.java +++ b/tools/southbound/southbound-service/src/main/java/com/openeuler/southbound/SouthBoundApplication.java @@ -12,8 +12,6 @@ package com.openeuler.southbound; -import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; - import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; @@ -25,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; */ @EnableScheduling @SpringBootApplication -@EnableEncryptableProperties public class SouthBoundApplication { public static void main(String[] args) { SpringApplication.run(SouthBoundApplication.class, args); diff --git a/tools/southbound/southbound-service/src/main/resources/application-dev.properties b/tools/southbound/southbound-service/src/main/resources/application-dev.properties index 01e1749..5443a92 100644 --- a/tools/southbound/southbound-service/src/main/resources/application-dev.properties +++ b/tools/southbound/southbound-service/src/main/resources/application-dev.properties @@ -1,11 +1,5 @@ # 数据库连接-开发数据库 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://10.136.2.208:3308/south_dash_board?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true -# ENC(加密的密文) -spring.datasource.username=ENC() -spring.datasource.password=ENC() - -# ENC加密使用salt设置 # 用来加密的salt值 -jasypt.encryptor.password=salt -jasypt.encryptor.algorithm=PBEWithMD5AndDES -jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator \ No newline at end of file +spring.datasource.url=jdbc:mysql://app:3306/south_dash_board?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true +spring.datasource.username= +spring.datasource.password= \ No newline at end of file diff --git a/tools/southbound/southbound-service/src/main/resources/application-prod.properties b/tools/southbound/southbound-service/src/main/resources/application-prod.properties index 97e7206..4f63dd3 100644 --- a/tools/southbound/southbound-service/src/main/resources/application-prod.properties +++ b/tools/southbound/southbound-service/src/main/resources/application-prod.properties @@ -1,8 +1,5 @@ -# 数据库连接-开发数据库 +# 数据库连接-生产数据库 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://mysql:3308/south_dash_board?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true -# ENC(加密的密文) -spring.datasource.username=ENC() -spring.datasource.password=ENC() -jasypt.encryptor.algorithm=PBEWithMD5AndDES -jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator \ No newline at end of file +spring.datasource.url= +spring.datasource.username= +spring.datasource.password= -- Gitee