Browse Source

修复docker容器无法限制JVM最大使用内存问题

niantuo 6 years ago
parent
commit
fe4486f822

+ 5 - 0
FRAMEWORK.md

@@ -88,6 +88,11 @@ Jetty 更加轻量化,更符合Spring Cloud 分布式部署;当然,这个
 - 更新User 字段,添加 avatar字段信息
 - 更新两个与安全有关的依赖包
 
+#### 2019/1/8
+
+- 解决docker 从容器无法限制JVM内存问题
+- 更改基础镜像为openjdk:8-jre-alpine (以前为8-jdk-alpine),减小镜像体积。
+
 ### 后期我的工作计划
 
 - 将继续精简shiro相关配置,直至完全移除;(已完成)

+ 2 - 2
zen-web/build.gradle

@@ -17,7 +17,7 @@ dependencies {
 }
 
 docker{
-    baseImage 'openjdk:8-jdk-alpine'
+    baseImage 'openjdk:8-jre-alpine'
     maintainer 'tina 976056042@qq.com'
     registry 'registry.cn-qingdao.aliyuncs.com'
 }
@@ -27,7 +27,7 @@ task dockerBuilder(type: Docker) {
     applicationName = 'fw'
     tagVersion = jar.version
     addFile("./${jar.baseName}-${jar.version}.jar","app.jar")
-    entryPoint(["java","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+08","-jar",'app.jar'])
+    entryPoint(["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+08","-jar",'app.jar'])
     exposePort(11000)
     doFirst {
         copy {

+ 2 - 0
zen-web/src/main/resources/application.yml

@@ -1,3 +1,5 @@
 spring:
   main:
     allow-bean-definition-overriding: true
+
+

+ 1 - 1
zen-web/src/main/resources/bootstrap.yml

@@ -30,7 +30,7 @@ eureka:
     prefer-ip-address: true
   client:
     service-url:
-      defaultZone: http://envir:envir@120.77.170.119:11001/eureka/
+      defaultZone: http://envir:envir@192.168.1.202:11001/eureka/
 
 ---
 spring: