作者 朱兆平

docker部署

@@ -12,7 +12,9 @@ target/ @@ -12,7 +12,9 @@ target/
12 .settings 12 .settings
13 .springBeans 13 .springBeans
14 .sts4-cache 14 .sts4-cache
15 - 15 +out/
  16 +logs/
  17 +log/
16 ### IntelliJ IDEA ### 18 ### IntelliJ IDEA ###
17 .idea 19 .idea
18 *.iws 20 *.iws
  1 +FROM java:8u111
  2 +
  3 +VOLUME /tmp
  4 +
  5 +ADD *.jar app.jar
  6 +
  7 +EXPOSE 10003
  8 +
  9 +ENTRYPOINT ["java","-jar","/app.jar"]
  10 +
  11 +# Ubuntu 时区
  12 +RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
@@ -33,6 +33,16 @@ @@ -33,6 +33,16 @@
33 <artifactId>spring-boot-starter-web</artifactId> 33 <artifactId>spring-boot-starter-web</artifactId>
34 </dependency> 34 </dependency>
35 <dependency> 35 <dependency>
  36 + <groupId>org.springframework.boot</groupId>
  37 + <artifactId>spring-boot-starter-websocket</artifactId>
  38 + <exclusions>
  39 + <exclusion>
  40 + <groupId>org.springframework.boot</groupId>
  41 + <artifactId>spring-boot-starter</artifactId>
  42 + </exclusion>
  43 + </exclusions>
  44 + </dependency>
  45 + <dependency>
36 <groupId>org.mybatis.spring.boot</groupId> 46 <groupId>org.mybatis.spring.boot</groupId>
37 <artifactId>mybatis-spring-boot-starter</artifactId> 47 <artifactId>mybatis-spring-boot-starter</artifactId>
38 <version>2.1.1</version> 48 <version>2.1.1</version>
@@ -191,6 +201,23 @@ @@ -191,6 +201,23 @@
191 </execution> 201 </execution>
192 </executions> 202 </executions>
193 </plugin> 203 </plugin>
  204 + <plugin>
  205 + <artifactId>maven-antrun-plugin</artifactId>
  206 + <executions>
  207 + <execution>
  208 + <id>gen-webadmin</id>
  209 + <phase>package</phase>
  210 + <configuration>
  211 + <tasks>
  212 + <copy todir="docker" file="target/${project.artifactId}-${project.version}.${project.packaging}" />
  213 + </tasks>
  214 + </configuration>
  215 + <goals>
  216 + <goal>run</goal>
  217 + </goals>
  218 + </execution>
  219 + </executions>
  220 + </plugin>
194 </plugins> 221 </plugins>
195 </build> 222 </build>
196 223
1 #上传文件的路径,要带斜杠 1 #上传文件的路径,要带斜杠
2 web: 2 web:
3 upload-path: upload/ 3 upload-path: upload/
  4 +docker:
  5 + server:
  6 + ip: 192.168.1.63
4 server: 7 server:
5 port: 10003 8 port: 10003
6 servlet: 9 servlet:
@@ -99,18 +102,19 @@ spring: @@ -99,18 +102,19 @@ spring:
99 eureka: 102 eureka:
100 instance: 103 instance:
101 #eureka服务器页面中status的请求路径 104 #eureka服务器页面中status的请求路径
102 - status-page-url: http://${eureka.instance.hostname}:${server.port}/ 105 + status-page-url: http://${docker.server.ip}:${server.port}/
103 prefer-ip-address: true 106 prefer-ip-address: true
104 - instance-id: ${spring.cloud.client.ip-address}:${server.port} 107 + instance-id: ${docker.server.ip}:${server.port}
105 hostname: ${spring.cloud.client.ip-address} 108 hostname: ${spring.cloud.client.ip-address}
  109 + lease-renewal-interval-in-seconds: 15
  110 + lease-expiration-duration-in-seconds: 45
106 client: 111 client:
107 #eureka注册中心服务器地址 112 #eureka注册中心服务器地址
108 service-url: 113 service-url:
109 # defaultZone: http://127.0.0.1:12345/eureka/ 114 # defaultZone: http://127.0.0.1:12345/eureka/
110 defaultZone: http://192.168.1.53:12345/eureka/ 115 defaultZone: http://192.168.1.53:12345/eureka/
111 registry-fetch-interval-seconds: 30 116 registry-fetch-interval-seconds: 30
112 - lease-renewal-interval-in-seconds: 15  
113 - lease-expiration-duration-in-seconds: 45 117 +
114 118
115 119
116 120
@@ -133,7 +137,7 @@ logging: @@ -133,7 +137,7 @@ logging:
133 file: 137 file:
134 path: ./logs/ 138 path: ./logs/
135 name: system.log 139 name: system.log
136 - config: config/logback-dev.xml 140 + config: classpath:logback-dev.xml
137 #转移到logback配置文件中 141 #转移到logback配置文件中
138 #level: 142 #level:
139 #org.apache.tomcat: info 143 #org.apache.tomcat: info