mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2025-12-06 02:56:44 -05:00
lots of changes that I don't think I made, must of been the pull
This commit is contained in:
34
docker/backend/Dockerfile
Normal file
34
docker/backend/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# Stage 1: Build the application (The Build Stage)
|
||||
# Use a Java SDK image with Maven pre-installed
|
||||
FROM maven:3.9-jdk-17-slim AS build
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Maven project files (pom.xml) first to leverage Docker layer caching
|
||||
COPY pom.xml .
|
||||
|
||||
# Copy the source code
|
||||
COPY src ./src
|
||||
|
||||
# Build the Spring Boot application, skipping tests to speed up the Docker build
|
||||
# This creates the executable JAR file in the 'target' directory
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
# Stage 2: Create the final lightweight image (The Runtime Stage)
|
||||
# Use a smaller Java Runtime Environment (JRE) image for a smaller footprint
|
||||
FROM openjdk:17-jre-slim
|
||||
|
||||
# Set the working directory in the final image
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built JAR file from the 'build' stage into the final image
|
||||
# The JAR file is typically named 'target/<your-app-name>-<version>.jar'
|
||||
# You may need to adjust the name if you have a non-standard pom.xml
|
||||
COPY --from=build /app/target/*.jar app.jar
|
||||
|
||||
# Expose the default Spring Boot port
|
||||
EXPOSE 8080
|
||||
|
||||
# Define the command to run the application
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
Reference in New Issue
Block a user