add Dockerfile
This commit is contained in:
parent
94d0bb2b42
commit
08f089ea3a
32
backend/Dockerfile
Normal file
32
backend/Dockerfile
Normal file
@ -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"]
|
||||||
Loading…
Reference in New Issue
Block a user