0

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
Vinod Jayachandran
  • 3,726
  • 8
  • 51
  • 88

1 Answers1

0

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"]
Vinod Jayachandran
  • 3,726
  • 8
  • 51
  • 88