DEV Community

Goffity Corleone
Goffity Corleone

Posted on • Edited on

1 1

Build a Docker container for spring-boot application.

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"]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more