feat: add Dockerfile and .dockerignore for containerized builds#6
Merged
Conversation
Multi-stage build with eclipse-temurin:21 (JDK for build, JRE for runtime). Includes .dockerignore to optimize build context. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds initial containerization support for the Spring Boot API so it can be built and run reproducibly via Docker using a multi-stage build.
Changes:
- Introduces a multi-stage
Dockerfile(build with Maven wrapper; runtime with non-root user and healthcheck). - Adds a
.dockerignoreto reduce build context size and improve caching.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Dockerfile | Multi-stage build/runtime image definition for the API container. |
| .dockerignore | Excludes common build artifacts/IDE/VCS files from Docker build context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
This project had no container support, making it harder to run consistently across environments. Adding a
Dockerfileand.dockerignoreenables building and running the API as a Docker image with a reproducible, production-ready setup.What changed
A multi-stage build approach is used to keep the final image lean:
build) —eclipse-temurin:21-jdk-alpine: copies the Maven wrapper andpom.xmlfirst to leverage Docker layer caching for dependencies (dependency:go-offline), then copiessrc/and produces the fat JAR viamvnw clean package -DskipTests.runtime) —eclipse-temurin:21-jre-alpine: copies only the built JAR, runs it as a non-root user (appuser) for security, exposes port8080, and includes aHEALTHCHECKagainst/actuator/health.The
.dockerignoreexcludes build artifacts (target/), IDE files, docs, and VCS metadata to keep the build context small and avoid accidentally invalidating cache layers.Notes
HEALTHCHECKprobes/actuator/health— addspring-boot-starter-actuatortopom.xmlif not already present, or update the endpoint accordingly.apk --no-cacheis not needed there.