diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8bb8189 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target +.git +*.log +*.tmp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..01ad0f7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use an official OpenJDK runtime as a parent image suitable for Java 17 +FROM openjdk:17-jdk + +# Set the working directory in the container +WORKDIR /app + +# Copy the Maven Wrapper and pom.xml to the container +COPY mvnw . +COPY pom.xml ./ + +# Copy the project source to the container +COPY src ./src + +# Make the mvnw file executable +RUN chmod +x mvnw + +# Verify the installed Java version +RUN java -version + +# Package the application code +RUN ./mvnw package -DskipTests + +# Move the built application to the app directory (assuming a typical target directory structure) +RUN mv target/*.jar app.jar + +# Make port 8080 available to the world outside this container +EXPOSE 8080 + +# Run the JAR file +CMD ["java", "-jar", "app.jar"] \ No newline at end of file