DockerHub Autobuild fails but succeeds in local

139 Views Asked by At

Docker build succeeds in my local but auto build on docker hub linked to my Github account fails. Can you please suggest where am I going wrong?

Dockerfile

FROM openjdk:8-jdk-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

My Build configuration on DockerHub

enter image description here

Here's Build Error

Step 5/6 : COPY ${JAR_FILE} app.jar
COPY failed: no source files were specified
1

There are 1 best solutions below

0
Vinod Jayachandran On

We need Multi Stage build here. Reference of my DockerFile below

#
# Build stage
#
FROM maven:3.6.0-jdk-11-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

#
# Package stage
#
FROM openjdk:11-jre-slim
COPY --from=build /home/app/target/*.jar /usr/local/lib/app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/usr/local/lib/app.jar"]