简体   繁体   中英

Issue building a java project inside a docker image (Memory issue)

I tried to build a java project with gradle wrapper with a dockerfile. But the build failed at some points with an error message related to memory issue and never finish. There is no issue when the build is done on the local machine.

the docker file:

FROM adoptopenjdk/openjdk11 as builder
COPY ./ ./
RUN ./gradlew build

The error message in loop:

08:16:17.039 [DEBUG]  [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 33576538112, Free: 16748404736}
08:16:17.039 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 33576538112, Free: 16748404736}
08:16:17.040 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 2147483648, Committed: 526385152}
08:16:17.310 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
08:16:17.311 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
08:16:17.311 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
08:16:17.311 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

The project uses 2 gradle plugins spring boot and org.openapi.generator.

I have tried to add a file 'gradle.properties' with this content:

org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Increasing the JVM memory limits is just one side of the bill. You need to increase docker's memory limits too!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM