Getting source code compilation failuer error with below docker file.
FROM openjdk:8-jdk-alpine AS base
EXPOSE 8080:8080
FROM maven:3.6.0-ibmjava-8 AS build
WORKDIR /mywrkdir
COPY src src
COPY pom.xml .
COPY settings.xml .
RUN mvn -s settings.xml clean package
FROM base AS final
COPY --from=build /mywrkdir/target/xxx.jar xxx.jar
ENTRYPOINT ["java","-Dspring.profiles.active=someEnvironmentVariable","-Djava.security.egd=file:/dev/./urandom","-jar","xxx.jar"]
There is settings.xml with some specific profiles and repositories needed for application to build. For that purpose used maven command. But at below stage getting compilation error.
RUN mvn -s settings.xml clean package
Command used to build the test image is as below
az acr build --registry MyAcr --image testimg .
Error log when building docker file . Nothing is getting compiled RUN mvn stage from dockerfile:
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 31 source files to /xxx /target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /xxxxxxx/xxxxxxx/xxx/.java:[10,17] package org.slf4j does not exist
[ERROR] /xxxxxxx/xxxxxxx/xxx/..java:[11,17] package org.slf4j does not exist
[ERROR] /xxxxxxx/xxxxxxx/xxx/..java:[12,52] package org.springframework.beans.factory.annotation does not exist
[ERROR] /xxxxxxx/xxxxxxx/xxx/..java:[13,38] package org.springframework.stereotype does not exis
[ERROR] /xxxxxxx/xxxxxxx/xxx/.java:[21,2] cannot find symbol
symbol: class Service
[ERROR] /xxxxxxx/xxxxxxx/xxx/.java:[24,30] cannot find symbol
symbol: class Logger
location: class
[ERROR] /xxxxxxx/xxxxxxx/xxx/.java:[3,17] package org.slf4j does not exist
[ERROR] /xxxxxxx/xxxxxxx/xxx/.java:[4,17] package org.slf4j does not exist
.
.
.
…….
[INFO] 100 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:10 min
[INFO] Finished at:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project xxxx: Compilation failure: Compilation failure