Docker build is failing at step RUN mvn package -DskipTests

112 Views Asked by At

My docker build which was working totally fine before is now failing at below step of docker.

RUN mvn package -DskipTests

Getting error:

failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c mvn package -DskipTests]: exit code: 1

Here is my whole docker file.

# Using a base image with JDK 11 and Gradle  
FROM maven:3.8.6-openjdk-11 AS build

# set as working directory
WORKDIR /app

# Copy files from your project to the working directory
COPY . /app

# Run Gradle to build the project
RUN mvn package -DskipTests

# Create a new image based on OpenJDK 11
FROM openjdk:11-jre-slim-buster

# Expose the port that the application will use 
EXPOSE 8080

# Copy the JAR file built from the previous step
COPY --from=build /app/target/kaim-backend-0.0.1-SNAPSHOT.jar /app/kaim-backend-0.0.1-SNAPSHOT.jar

# Set the entry point to run the application 
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "/app/kaim-backend-0.0.1-SNAPSHOT.jar"]

Earlier it was working fine; but just out of nowhere, I got this issue, and now deployments are stuck.

I am using flyctl for deploying my Docker build and running my application.

0

There are 0 best solutions below