<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a" -->

---
title: adam bien's blog | daily.dev
description: Multi-stage Docker builds are criticized as an antipattern for Java shops that already have a Maven or Gradle CI/CD pipeline compiling, testing, and versioning...
canonical: https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: adam bien's blog | daily.dev
og:description: Multi-stage Docker builds are criticized as an antipattern for Java shops that already have a Maven or Gradle CI/CD pipeline compiling, testing, and versioning...
og:url: https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a
og:image: https://api.daily.dev/og/posts/0Nd2pyI2A.png
og:image:alt: adam bien's blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# adam bien's blog

**[Adam Bien](https://daily.dev/sources/adam-bien)** · 2 min read · 2 upvotes · 1 comments

## Summary

Multi-stage Docker builds are criticized as an antipattern for Java shops that already have a Maven or Gradle CI/CD pipeline compiling, testing, and versioning artifacts. Rebuilding inside Docker means the image no longer contains the exact artifact that passed the pipeline's tests, just a similar rebuild sharing the same commit. The recommended alternative is a single-stage Dockerfile that copies the already-built jar into a minimal runtime image (e.g. eclipse-temurin:25-jre-alpine), reserving multi-stage builds for cases where Docker itself is the chosen build environment.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://adambien.blog/roller/abien/entry/multi_stage_docker_builds_are_an_antipattern_in_most_java_pr>

## Questions this post answers

### Should I use a multi-stage Dockerfile for a Java application that already has a CI/CD pipeline building it with Maven or Gradle?

No, a single-stage Dockerfile is preferable when a CI/CD pipeline already compiles, tests, and versions the artifact in a controlled environment. Multi-stage builds recompile the source a second time inside Docker with a different JDK and cache, meaning the image no longer contains the exact artifact that passed tests. A single-stage Dockerfile that copies the already-built jar (e.g. into eclipse-temurin:25-jre-alpine) preserves build integrity.

_Developers designing Docker packaging strategies can weigh trade-offs like this on daily.dev._

### What is the risk of recompiling a Java application inside a Docker multi-stage build instead of using the CI pipeline's artifact?

The risk is that the deployed image contains a rebuild rather than the exact artifact that passed the CI pipeline's tests. A multi-stage Docker build compiles the source again using a potentially different JDK version, a different local dependency repository, and a different build cache, so the resulting binary only shares the same commit as the tested artifact, not its verified bytes.

_Teams debating build reproducibility in CI/CD can explore this reasoning on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> I think CI should promote the exact artifact it tested into the runtime image

## Similar posts on daily.dev

- [Why To Use A Multi-Stage Dockerfile](https://daily.dev/posts/why-to-use-a-multi-stage-dockerfile-ripe33vzt) · RUBYLAND · 0 upvotes · 0 comments
- [Containerizing Java, Python, and JavaScript Apps - Multi-Stage Docker Builds, Non-Root Users, and Docker Hub Tagging](https://daily.dev/posts/containerizing-java-python-and-javascript-apps---multi-stage-docker-builds-non-root-users-and-do-ancbrg46f) · Medium · 22 upvotes · 0 comments
- [Building the Perfect Docker Image for a Java app](https://daily.dev/posts/building-the-perfect-docker-image-for-a-java-app-wf0dbjzj1) · Vaadin · 1 upvotes · 0 comments
- [Java Code Isn’t the Problem](https://daily.dev/posts/java-code-isn-t-the-problem-ekyxiyuk9) · Container Journal · 9 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#architecture](https://daily.dev/tags/architecture), [#cicd](https://daily.dev/tags/cicd), [#docker](https://daily.dev/tags/docker), [#maven](https://daily.dev/tags/maven)

[View this post on daily.dev](https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"adam bien's blog","url":"https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a"},"datePublished":"2026-08-18T13:20:11.239Z","dateModified":"2026-09-14T08:21:05.189Z","description":"Multi-stage Docker builds are criticized as an antipattern for Java shops that already have a Maven or Gradle CI/CD pipeline compiling, testing, and versioning...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d365e8cabb5d95ba36aaa092c23f211d?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d365e8cabb5d95ba36aaa092c23f211d?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Adam Bien","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Adam Bien","logo":"https://media.daily.dev/image/upload/s--CInnAL-q--/f_auto,q_auto/v1773644276/logos/adam-bien?_a=BAMAMiiu0","url":"https://daily.dev/sources/adam-bien"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"java,architecture,cicd,docker,maven","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Adam Bien","item":"https://daily.dev/sources/adam-bien"},{"@type":"ListItem","position":3,"name":"adam bien's blog"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a","comment":[{"@type":"Comment","text":"I think CI should promote the exact artifact it tested into the runtime image","datePublished":"2026-08-18T21:14:38.268Z","url":"https://daily.dev/posts/0Nd2pyI2A#c-gThgLiPth","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/adam-bien-s-blog-0nd2pyi2a#faq","mainEntity":[{"@type":"Question","name":"Should I use a multi-stage Dockerfile for a Java application that already has a CI/CD pipeline building it with Maven or Gradle?","acceptedAnswer":{"@type":"Answer","text":"No, a single-stage Dockerfile is preferable when a CI/CD pipeline already compiles, tests, and versions the artifact in a controlled environment. Multi-stage builds recompile the source a second time inside Docker with a different JDK and cache, meaning the image no longer contains the exact artifact that passed tests. A single-stage Dockerfile that copies the already-built jar (e.g. into eclipse-temurin:25-jre-alpine) preserves build integrity. Developers designing Docker packaging strategies can weigh trade-offs like this on daily.dev."}},{"@type":"Question","name":"What is the risk of recompiling a Java application inside a Docker multi-stage build instead of using the CI pipeline's artifact?","acceptedAnswer":{"@type":"Answer","text":"The risk is that the deployed image contains a rebuild rather than the exact artifact that passed the CI pipeline's tests. A multi-stage Docker build compiles the source again using a potentially different JDK version, a different local dependency repository, and a different build cache, so the resulting binary only shares the same commit as the tested artifact, not its verified bytes. Teams debating build reproducibility in CI/CD can explore this reasoning on daily.dev."}}]}
```

