diff --git a/.Dockerfile.swp b/.Dockerfile.swp new file mode 100644 index 00000000..5cd53cd8 Binary files /dev/null and b/.Dockerfile.swp differ diff --git a/Dockerfile b/Dockerfile index 079acabe..28c1e21e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,10 @@ -#---------------------------------- -# Stage 1 -#---------------------------------- +FROM maven:3.9.6-eclipse-temurin-17-alpine AS builder #new base image added +workdir /app +copy . . +run mvn clean install -DskipTests=true +from openjdk:17-slim +workdir /app +COPY --from=builder /app/target/*.jar /app/app.jar +expose 8080 +cmd ["java","-jar","/app/app.jar"] -# Import docker image with maven installed -FROM maven:3.8.3-openjdk-17 as builder - -# Add maintainer, so that new user will understand who had written this Dockerfile -MAINTAINER Madhup Pandey - -# Add labels to the image to filter out if we have multiple application running -LABEL app=bankapp - -# Set working directory -WORKDIR /src - -# Copy source code from local to container -COPY . /src - -# Build application and skip test cases -RUN mvn clean install -DskipTests=true - -#-------------------------------------- -# Stage 2 -#-------------------------------------- - -# Import small size java image -FROM openjdk:17-alpine as deployer - -# Copy build from stage 1 (builder) -COPY --from=builder /src/target/*.jar /src/target/bankapp.jar - -# Expose application port -EXPOSE 8080 - -# Start the application -ENTRYPOINT ["java", "-jar", "/src/target/bankapp.jar"]