loading...

Build a Docker container for spring-boot application.

goffity profile image goffity ・1 min read

Reduce a docker image size of spring-boot application by dockerfile multiple-stage.

# Create builder stage for build application.
FROM maven:3-openjdk-8 as builder

WORKDIR /app

COPY . /app

# Build maven application
RUN mvn clean package

RUN mv target/*.jar app.jar

# Reduce image size
FROM openjdk:8-jdk-alpine

WORKDIR /app

COPY --from=builder /app/app.jar /app/app.jar

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]

Discussion

markdown guide