Closed HarikrishnanBalagopal closed 2 years ago
The maven build fails for a similar reason
[+] Building 2.0s (17/17) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.57kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for registry.access.redhat.com/ubi8/ubi-minimal:latest 1.4s
=> [internal] load metadata for registry.access.redhat.com/ubi8/ubi:latest 1.9s
=> [builder 1/6] FROM registry.access.redhat.com/ubi8/ubi:latest@sha256:228824aa581f3b31bf79411f8448b798291c667a37155bdea61cfa128b2833f2 0.0s
=> [stage-1 1/6] FROM registry.access.redhat.com/ubi8/ubi-minimal:latest@sha256:cf1c63e3247e4074ee3549a064b8798a1a2513ad57dd79c9edb979836355b469 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 4.31kB 0.0s
=> CACHED [stage-1 2/6] RUN microdnf update && microdnf install -y java-11-openjdk-devel wget tar && microdnf clean all 0.0s
=> CACHED [stage-1 3/6] WORKDIR /usr/local 0.0s
=> CACHED [stage-1 4/6] RUN wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz && tar -zxf apache-tomcat-9.0.56.tar.gz && rm -f apache-tomcat-9.0.56.tar.gz && mv apache-tomcat-9.0.56 tomcat9 0.0s
=> CACHED [stage-1 5/6] RUN useradd -r tomcat && chown -R tomcat:tomcat tomcat9 0.0s
=> CACHED [builder 2/6] RUN yum install -y java-1.8.0-openjdk-devel 0.0s
=> CACHED [builder 3/6] RUN yum install -y maven 0.0s
=> CACHED [builder 4/6] COPY . /app 0.0s
=> CACHED [builder 5/6] WORKDIR /app 0.0s
=> CACHED [builder 6/6] RUN mvn package -Dmaven.test.skip 0.0s
=> ERROR [stage-1 6/6] COPY --chown=tomcat:tomcat --from=builder /app/target/simplewebapp-1.0.war /usr/local/tomcat9/webapps/ 0.0s
------
> [stage-1 6/6] COPY --chown=tomcat:tomcat --from=builder /app/target/simplewebapp-1.0.war /usr/local/tomcat9/webapps/:
------
failed to compute cache key: "/app/target/simplewebapp-1.0.war" not found: not found
/Users/user/Desktop/tutorial/myproject
Describe the bug There are some issues with the Dockerfile that is generated by the java-gradle transformer which causes the build to fail:
To Reproduce
plan
andtransform
on thelanguage-platforms.zip
Expected behavior
gradlew
wrapper script.RUN gradle build
should beRUN /gradlew build
.gradlew
is a script which downloads the correct version of gradle, caches it locally and runs the task (in this casebuild
).COPY --from=builder /app/target/myproject-java-gradlejar .
This is wrong because for webapps the output is a war file. This can be detected by looking for thewar
plugin in thebuild.gradle
https://github.com/konveyor/move2kube-demos/blob/main/samples/language-platforms/java-gradle/build.gradle#L3build/libs/<project-name>.war
. The default archive name is<project-name>.war
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.War.html The project name is given in thesettings.gradle
file https://github.com/konveyor/move2kube-demos/blob/main/samples/language-platforms/java-gradle/settings.gradle#L1 The default filename can also be changed (in this caseROOT.war
) https://github.com/konveyor/move2kube-demos/blob/main/samples/language-platforms/java-gradle/build.gradle#L13FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
The runner image does not have Tomcat or a similar web server to run the.war
file that is generated.CMD ["java", "-jar", "myproject-java-gradlejar"]
The final command to run is also wrong. It should start up the webserver. (startup.sh
in case of Tomcat).RUN yum install -y java-1.8.0-openjdk-devel
We can potentially use the latest JDK because Gradle allows you to select the exact version you want https://github.com/konveyor/move2kube-demos/blob/main/samples/language-platforms/java-gradle/build.gradle#L8 This has been tested and allows building for jdk 8 using jdk 17.Working Dockerfile (build and deploy suceeds)