mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2025-12-05 18:46: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"]
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Stage 1: Build the application
|
|
||||||
FROM openjdk:17-jdk-slim as build
|
|
||||||
WORKDIR /app
|
|
||||||
COPY gradlew .
|
|
||||||
COPY settings.gradle .
|
|
||||||
COPY build.gradle .
|
|
||||||
COPY src ./src
|
|
||||||
# Adjust the build command for Maven: ./mvnw package -DskipTests
|
|
||||||
RUN ./gradlew bootJar
|
|
||||||
|
|
||||||
# Stage 2: Create the final lightweight image
|
|
||||||
FROM openjdk:17-jre-slim
|
|
||||||
WORKDIR /app
|
|
||||||
# Get the built JAR from the build stage
|
|
||||||
COPY --from=build /app/build/libs/*.jar app.jar
|
|
||||||
EXPOSE 8080
|
|
||||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
|
||||||
@@ -14,10 +14,13 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping()
|
@RequestMapping()
|
||||||
public class UserController {
|
public class UserController {
|
||||||
@Autowired
|
private final UserRepository repo;
|
||||||
private UserRepository repo;
|
private final UsersService usersService;
|
||||||
@Autowired
|
|
||||||
private UsersService usersService;
|
public UserController(UserRepository repo, UsersService usersService) {
|
||||||
|
this.repo = repo;
|
||||||
|
this.usersService = usersService;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/api/getAllUsers")
|
@GetMapping("/api/getAllUsers")
|
||||||
public ResponseEntity<List<User>> getAllUsers() {
|
public ResponseEntity<List<User>> getAllUsers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user