skip to Main Content

I need your help I got project to do and I don’t know how to start it ,I hope do you are can help me .

and this repository: https://github.com/spring-guides/top-spring-boot-docker

First thing I built a Dockerfile According to README, I make Dockefile from repository to my host

FROM openjdk:8-jdk-alpine as build
WORKDIR /workspace/app

COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
RUN --mount=type=cache,target=/root/.m2 ./mvnw install -DskipTests

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} target/application.jar
RUN java -Djarmode=layertools -jar target/application.jar extract --destination target/extracted

FROM openjdk:8-jdk-alpine
RUN addgroup -S demo && adduser -S demo -G demo
VOLUME /tmp
USER demo
ARG EXTRACTED=/workspace/app/target/extracted
WORKDIR application
COPY --from=build ${EXTRACTED}/dependencies/ ./
COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./
COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./
COPY --from=build ${EXTRACTED}/application/ ./
ENTRYPOINT ["java","-noverify","-XX:TieredStopAtLevel=1","-Dspring.main.lazy-initialization=true","org.springframework.boot.loader.JarLauncher"]

After I build the Dockerfile

C:UsersLSDesktopJobTest>docker build -t myorg/myapp .

    [+] Building 6.4s (13/19)
     => [internal] load build definition from Dockerfile                                                               0.0s
     => => transferring dockerfile: 32B                                                                                0.0s
     => [internal] load .dockerignore                                                                                  0.0s
     => => transferring context: 2B                                                                                    0.0s
     => [internal] load metadata for docker.io/library/openjdk:8-jdk-alpine                                            3.6s
     => [internal] load build context                                                                                  0.0s
     => => transferring context: 897B                                                                                  0.0s
     => [stage-1 1/7] FROM docker.io/library/openjdk:8-jdk-alpine@sha256:94792824df2df33402f201713f932b58cb9de94a0cd5  0.0s
     => CACHED [stage-1 2/7] RUN addgroup -S demo && adduser -S demo -G demo                                           0.0s
     => CACHED [stage-1 3/7] WORKDIR application                                                                       0.0s
     => CACHED [build 2/9] WORKDIR /workspace/app                                                                      0.0s
     => CACHED [build 3/9] COPY mvnw .                                                                                 0.0s
     => CACHED [build 4/9] COPY .mvn .mvn                                                                              0.0s
     => CACHED [build 5/9] COPY pom.xml .                                                                              0.0s
     => CACHED [build 6/9] COPY src src                                                                                0.0s
     => ERROR [build 7/9] RUN --mount=type=cache,target=/root/.m2 ./mvnw install -DskipTests                           2.7s
    ------
     > [build 7/9] RUN --mount=type=cache,target=/root/.m2 ./mvnw install -DskipTests:
    #13 1.665 [INFO] Scanning for projects...
    #13 1.898 [INFO]
    #13 1.898 [INFO] --------------------------< com.example:demo >--------------------------
    #13 1.898 [INFO] Building demo 0.0.1-SNAPSHOT
    #13 1.898 [INFO] --------------------------------[ jar ]---------------------------------
    #13 2.166 [INFO]
    #13 2.167 [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ demo ---
    #13 2.454 [INFO] Using 'UTF-8' encoding to copy filtered resources.
    #13 2.454 [INFO] Using 'UTF-8' encoding to copy filtered properties files.
    #13 2.460 [INFO] Copying 1 resource
    #13 2.492 [INFO] Copying 0 resource
    #13 2.494 [INFO]
    #13 2.494 [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ demo ---
    #13 2.608 [INFO] Changes detected - recompiling the module!
    #13 2.612 [INFO] Compiling 1 source file to /workspace/app/target/classes
    #13 2.683 [INFO] ------------------------------------------------------------------------
    #13 2.683 [INFO] BUILD FAILURE
    #13 2.683 [INFO] ------------------------------------------------------------------------
    #13 2.685 [INFO] Total time:  1.040 s
    #13 2.685 [INFO] Finished at: 2022-06-24T11:36:26Z
    #13 2.685 [INFO] ------------------------------------------------------------------------
    #13 2.687 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 17 -> [Help 1]
    #13 2.687 [ERROR]
    #13 2.687 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    #13 2.687 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    #13 2.687 [ERROR]
    #13 2.688 [ERROR] For more information about the errors and possible solutions, please read the following articles:
    #13 2.688 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    ------
    executor failed running [/bin/sh -c ./mvnw install -DskipTests]: exit code: 1

2

Answers


  1. Please look more at line, you could provide a correct jdk version.
    #13 2.687 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 17 -> [Help 1]

    Login or Signup to reply.
  2. The javac in the docker image is too Old to be able to compile Java 17 code

    Either convert to java 8 or use a java17-based image.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search