-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Dockerfile and .dockerignore for containerized builds #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .git | ||
| .github | ||
| target/ | ||
| *.md | ||
| .gitignore | ||
| .idea/ | ||
| *.iml | ||
| .vscode/ | ||
| .DS_Store | ||
| docker-compose*.yml |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||
| # Stage 1 - Build | ||||||||||
| FROM eclipse-temurin:21-jdk-alpine AS build | ||||||||||
|
|
||||||||||
| WORKDIR /app | ||||||||||
|
|
||||||||||
| COPY mvnw . | ||||||||||
| COPY .mvn .mvn | ||||||||||
| COPY pom.xml . | ||||||||||
|
|
||||||||||
| RUN chmod +x mvnw && ./mvnw dependency:go-offline -B | ||||||||||
|
|
||||||||||
| COPY src src | ||||||||||
|
|
||||||||||
| RUN ./mvnw clean package -DskipTests -B | ||||||||||
|
|
||||||||||
| # Stage 2 - Runtime | ||||||||||
| FROM eclipse-temurin:21-jre-alpine AS runtime | ||||||||||
|
|
||||||||||
| LABEL maintainer="felipementel" \ | ||||||||||
| description="CRUD de usuarios em Spring Boot com Ports and Adapters" | ||||||||||
|
|
||||||||||
| RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||||||||||
|
|
||||||||||
| WORKDIR /app | ||||||||||
|
|
||||||||||
| COPY --from=build /app/target/usuarios-api-java-0.1.0.jar app.jar | ||||||||||
|
|
||||||||||
| RUN chown appuser:appgroup app.jar | ||||||||||
|
|
||||||||||
|
Comment on lines
+26
to
+29
|
||||||||||
| COPY --from=build /app/target/usuarios-api-java-0.1.0.jar app.jar | |
| RUN chown appuser:appgroup app.jar | |
| COPY --chown=appuser:appgroup --from=build /app/target/usuarios-api-java-0.1.0.jar app.jar |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HEALTHCHECK targets /actuator/health, but this repo currently doesn't include spring-boot-starter-actuator (and the codebase already exposes /health/live and /health/ready). As written, containers will be marked unhealthy due to a 404. Update the HEALTHCHECK to hit an existing endpoint (e.g. /health/ready) or add Actuator and ensure the endpoint is enabled in config.
| CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1 | |
| CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health/ready || exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime stage copies a version-pinned JAR name (
usuarios-api-java-0.1.0.jar). This will break the Docker build whenever the project version changes or if the artifact name is customized. Consider producing a stable output name during the build (e.g., configure MavenfinalNametoapp) and copy that, or otherwise avoid hard-coding the version in the Dockerfile.