Well, there is this java project using maven, and the pom.xml file is like THIS
When I run locally ./mvnw -B dependency:go-offline and ./mvnw -o package -DskipTests, it works fine. However when I use it in Dockerfile, it just fails on some dependencies...
This is my Dockerfile:
FROM eclipse-temurin:18.0.2.1_1-jdk-focal AS builder
ENV APP=/home/meapi/app
WORKDIR $APP
COPY .mvn .mvn
COPY mvnw pom.xml ./
RUN ./mvnw -B dependency:go-offline
COPY src src
RUN ./mvnw -o package -DskipTests
FROM eclipse-temurin:18.0.2.1_1-jre-focal as dev
RUN addgroup --system meapi && adduser --system --group meapi
ENV spring_profiles_active=development
ENV APP=/home/meapi/app
WORKDIR $APP
RUN chown -R meapi:meapi $APP
USER meapi
COPY --chown=meapi:meapi --from=builder $APP/target/*.jar $APP/app.jar
EXPOSE 8080
ENTRYPOINT [ "java", "-jar", "/usr/meapi/app/app.jar" ]
This is the error:
=> ERROR [builder 7/7] RUN ./mvnw -o package -DskipTests 12.9s
------
> [builder 7/7] RUN ./mvnw -o package -DskipTests:
#14 7.221 [INFO] Scanning for projects...
#14 8.659 [INFO]
#14 8.659 [INFO] ---------------------< com.me:me-api >----------------------
#14 8.660 [INFO] Building me-api 0.0.1-SNAPSHOT
#14 8.660 [INFO] --------------------------------[ jar ]---------------------------------
#14 10.43 [WARNING] The POM for javax.xml.bind:jaxb-api:jar:2.3.1 is missing, no dependency information available
#14 11.03 [WARNING] The POM for com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.13.3 is missing, no dependency information available
#14 11.11 [WARNING] The POM for net.minidev:json-smart:jar:2.4.8 is missing, no dependency information available
#14 11.19 [WARNING] The POM for net.bytebuddy:byte-buddy:jar:1.12.10 is missing, no dependency information available
#14 11.20 [WARNING] The POM for net.bytebuddy:byte-buddy-agent:jar:1.12.10 is missing, no dependency information available
#14 11.35 [WARNING] The POM for org.glassfish.jaxb:jaxb-runtime:jar:2.3.6 is missing, no dependency information available
#14 12.79 [INFO] ------------------------------------------------------------------------
#14 12.79 [INFO] BUILD FAILURE
#14 12.79 [INFO] ------------------------------------------------------------------------
#14 12.82 [INFO] Total time: 5.758 s
#14 12.83 [INFO] Finished at: 2022-09-13T19:58:59Z
#14 12.83 [INFO] ------------------------------------------------------------------------
#14 12.85 [ERROR] Failed to execute goal on project me-api: Could not resolve dependencies for project com.me:me-api:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.xml.bind:jaxb-api:jar:2.3.1, com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.13.3, net.minidev:json-smart:jar:2.4.8, net.bytebuddy:byte-buddy:jar:1.12.10, net.bytebuddy:byte-buddy-agent:jar:1.12.10, org.glassfish.jaxb:jaxb-runtime:jar:2.3.6: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact javax.xml.bind:jaxb-api:jar:2.3.1 has not been downloaded from it before. -> [Help 1]
#14 12.85 [ERROR]
#14 12.85 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
#14 12.85 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
#14 12.85 [ERROR]
#14 12.85 [ERROR] For more information about the errors and possible solutions, please read the following articles:
#14 12.85 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
------
executor failed running [/bin/sh -c ./mvnw -o package -DskipTests]: exit code: 1
The command I use to run it is docker build --no-cache --platform linux/amd64 --tag api --target dev .. How am I supposed to proceed and successfully build the image?