Gradle build is so slow in docker

Before

FROM gradle:6.2.1-jdk11

RUN gradle --version && java -version 

WORKDIR /app

COPY ./ /app/

RUN gradle clean build --no-daemon

CMD java -jar build/libs/*.jar 




AFTER

FROM gradle:6.2.1-jdk11

RUN gradle --version && java -version 

WORKDIR /app

# Only copy dependency-related files
COPY build.gradle gradle.properties settings.gradle /app/

# Only download dependencies
# Eat the expected build failure since no source code has been copied yet
RUN gradle clean build --no-daemon > /dev/null 2>&1 || true

# Copy all files
COPY ./ /app/

# Do the actual build
RUN gradle clean build --no-daemon

CMD java -jar build/libs/*.jar












Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch