-1

i am building multi module springboot application and i want to setup docker environmenta, but unable to build container, can someone please help me to solve this issue. My Docker file is mentioned below.

FROM openjdk:8-jdk
RUN apt-get update && apt-get install -y unzip
MAINTAINER zaihamm
COPY . .
WORKDIR /app/orderme
RUN curl -L https://services.gradle.org/distributions/gradle-7.1-bin.zip -o gradle- 
7.1-bin.zip
RUN unzip gradle-7.1-bin.zip
ENV GRADLE_HOME=/app/orderme/gradle/gradle-7.1
ENV PATH=$PATH:$GRADLE_HOME/bin
RUN gradle --version
RUN ./gradlew :admin-service:build -x test
ENTRYPOINT ["java", "-jar","/admin-service/build/libs/admin-service.jar"]

when i run docker build -t orderme ./ its giving error enter image description here

ZaihamM Code
  • 87
  • 4
  • 12
  • 1
    most likely GRADLE_HOME folder is wrong, unzipping probably results in `gradle-7.1-bin` or something. In order to not have these small issues just create a normal docker container from that image, connect to it with terminal and run commands one by one manually. After you have figured out everything you need just use `history` command to copy-paste commands you need into dockerfile – J Asgarov Jan 29 '22 at 08:15
  • unable to create container with that image, thats the issue – ZaihamM Code Jan 29 '22 at 08:22
  • 1
    another thing is - there is actually no need to install gradle and build inside of container, if anything that is wasteful of resources - in your dockerfile just copy the jar from build folder and run it with java alone `java -jar your_jar.jar`. Last but not least you have the option of using `google jib` plugin to pack your applicaiton in ready to use docker image - more here: https://javamondays.com/letting-gradle-and-google-jib-create-dokcer-images-for-you/ – J Asgarov Jan 29 '22 at 08:27

1 Answers1

2

Unzip do not create extra "gradle" directory - line 8 should look like:

ENV GRADLE_HOME=/app/orderme/gradle-7.1
Egor
  • 523
  • 4
  • 15