diff --git a/tools/southbound/docker-compose.yaml b/tools/southbound/docker-compose.yaml index a5159f564efe30e06eb0ddf9a27d0cdeb4000abc..47df194a9d3ed23b11e63333958c4dd7304516c1 100644 --- a/tools/southbound/docker-compose.yaml +++ b/tools/southbound/docker-compose.yaml @@ -7,7 +7,7 @@ services: # 服务名称 container_name: southbound-nginx # 指定上下文目录以及docker配置文件的相对路径 - build: ./southbound-view/DockerAppFile + build: ./southbound-view/ # 自动重启,如果服务启动不成功会一直尝试。 restart: always # 对外开放的端口。这里主机的端口映射到nginx容器端口,和expose的区别是,expose不会将端口暴露给主机。 @@ -46,7 +46,7 @@ services: app: container_name: southbound-server - build: ./southbound-service/DockerAppFile + build: ./southbound-service/ restart: always #设置工作目录为容器内的app文件夹 working_dir: /app diff --git a/tools/southbound/southbound-service/DockerAppFile b/tools/southbound/southbound-service/DockerAppFile index 97ad5f468585bee54b983a8d97ee54aae4e2a860..5bc2fcd5bd59be71d35549eb63657e2759ffad48 100644 --- a/tools/southbound/southbound-service/DockerAppFile +++ b/tools/southbound/southbound-service/DockerAppFile @@ -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/Dockerfile b/tools/southbound/southbound-service/Dockerfile index 5bc2fcd5bd59be71d35549eb63657e2759ffad48..d4395eaecf4693ef800bc073c590e1b9bee22c8f 100644 --- a/tools/southbound/southbound-service/Dockerfile +++ b/tools/southbound/southbound-service/Dockerfile @@ -1,30 +1 @@ -# 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 +FROM maven:3.6.3-openjdk-15 \ 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 4f63dd3b5b9893665e6531496a6bc79e3ef7c205..970b4cfbe3ccd15dc029fd670b620386d760c516 100644 --- a/tools/southbound/southbound-service/src/main/resources/application-prod.properties +++ b/tools/southbound/southbound-service/src/main/resources/application-prod.properties @@ -1,5 +1,5 @@ # 数据库连接-生产数据库 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url= +spring.datasource.url=jdbc:mysql://127.0.0.1:3306/south_dash_board?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true spring.datasource.username= -spring.datasource.password= +spring.datasource.password= \ No newline at end of file diff --git a/tools/southbound/southbound-view/DockerAppFile b/tools/southbound/southbound-view/DockerAppFile index 0e2901746be5dbdb179282abca0aed7607e3beaf..03c49a709573326c3e76980a6d5a31cddaf66d58 100644 --- a/tools/southbound/southbound-view/DockerAppFile +++ b/tools/southbound/southbound-view/DockerAppFile @@ -13,8 +13,10 @@ RUN mkdir -p /app WORKDIR /app COPY --from=Builder /app/dist /app RUN chmod -R 755 /app -COPY --from=Builder /app/nginx.conf /etc/nginx/conf.d/ -ENV RUN_USER nginx -ENV RUN_GROUP nginx +# 这里nginx配置复制过去 +ADD nginx.template /etc/nginx/conf.d EXPOSE 80 -ENTRYPOINT ["nginx", "-g", "daemon off;"] +EXPOSE 443 +WORKDIR /etc/nginx/conf.d +ENTRYPOINT envsubst '$URL' < nginx.template > default.conf && cat default.conf && nginx -g 'daemon off;' + diff --git a/tools/southbound/southbound-view/Dockerfile b/tools/southbound/southbound-view/Dockerfile index f76e55c9b32e86851f1f7a37ae287993c50adc77..7b9e2e85d338ffc53172d93f216b114bbd38b3f5 100644 --- a/tools/southbound/southbound-view/Dockerfile +++ b/tools/southbound/southbound-view/Dockerfile @@ -1,21 +1,17 @@ -FROM node:14.17.3-alpine as Builder +FROM node:14 as Builder RUN mkdir -p /app WORKDIR /app COPY . /app -RUN npm install -g cnpm -registry=https://registry.npm.taobao.org -RUN cnpm install -g vue && \ - cnpm install && \ - cnpm run build +RUN cnpm install && npm run build -FROM nginx:1.20.0 +FROM nginx:alpine RUN mkdir -p /app WORKDIR /app COPY --from=Builder /app/dist /app RUN chmod -R 755 /app -# 这里nginx配置复制过去 -ADD nginx.template /etc/nginx/conf.d +COPY --from=Builder /app/nginx.conf /etc/nginx/conf.d/ +ENV RUN_USER nginx +ENV RUN_GROUP nginx EXPOSE 80 -EXPOSE 443 -WORKDIR /etc/nginx/conf.d -ENTRYPOINT envsubst '$URL' < nginx.template > default.conf && cat default.conf && nginx -g 'daemon off;' \ No newline at end of file +ENTRYPOINT ["nginx", "-g", "daemon off;"] \ No newline at end of file