Dockerfile for springboot project

We are moving are deployment to Qovery. Our application is based on sprintboot and expose REST API only. The application is deployed on an ec2 instance and connects to a RDS Server in the same aws az. Also the application is exposed to the internet via a load balancer. Can you provide a docker file for this purpose.

Hi @Syed_Iftekhar_Ahmed :wave: ,

Can you please provide your Maven (or Gradle) version and the Java version you’re using? Happy to provide you with the first Dockerfile that could fit your need.

Maven 3.6.3
Spring Boot 1.5.14.RELEASE
OpenJDK Runtime Environment (build 1.8.0_282-bre_2021_01_20_16_06-b00)

Here is a good start

# Start with a base image containing Java runtime
FROM openjdk:8u282-buster #feel free to change this

# Make the project folder
RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

# Copy your Maven project files
COPY . .

# Install maven
RUN apt-get update
RUN apt-get install -y maven

# Verify the installation
RUN mvn --version

# Package the application
RUN mvn package -DskipTests

# Run the jar file 
ENTRYPOINT ["java","-jar","target/my-application.jar"]

Please replace my-application.jar with the actual name of your jar file. If your application requires any specific environment variables to be set, or any additional setup, you might need to modify this Dockerfile to accommodate those requirements. Also, be sure to replace the ‘.’ in the ‘COPY .’ command with the path to your actual project files if they’re not in the same directory as your Dockerfile.