From 08f089ea3a4476243ba814b685e8f12c76719199 Mon Sep 17 00:00:00 2001 From: Halit Aksoy Date: Sun, 19 Jan 2025 13:52:31 +0300 Subject: [PATCH] add Dockerfile --- backend/Dockerfile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..fb931ac --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,32 @@ +# Use a base image with Java 17 +FROM openjdk:17-jdk-slim AS build + +# Set the working directory in the container +WORKDIR /app + +# Copy Gradle wrapper and configuration files +COPY gradlew . +COPY gradle/ gradle/ +COPY build.gradle . +COPY settings.gradle . + +# Copy the source code +COPY src/ src/ + +# Make Gradle wrapper executable and build the application +RUN ./gradlew build + +# Use a smaller runtime image for the final build +FROM openjdk:17-jdk-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the built application from the build stage +COPY --from=build /app/build/libs/*.jar app.jar + +# Expose port 8080 +EXPOSE 8080 + +# Run the application +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file