Facing error while building docker.

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 just out of nowhere issue started coming andnow deployments are stuck.

Am using flyctl for deploying my docker build and running application.

A general approach to solving problems like these.

Create a file named Dockerfile.min with the following contents:

FROM maven:3.8.6-openjdk-11
WORKDIR /app
COPY . /app

Now run:

fly console --dockerfile Dockerfile.min -C /bin/bash

Once that gets you to a command prompt, run your command:

mvn package -DskipTests

The output will come to your screen. Given the information you posted, all we know is that this command failed. Hopefully the output tells you why.

Yes there was something wrong with dependecies i rolled back my branch then it started working again

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.