Skip to content

Commit d9d382a

Browse files
authored
felipementel@hotmail.com
feat: add Dockerfile and .dockerignore for containerized builds
2 parents de090f8 + 95561d2 commit d9d382a

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.git
2+
.github
3+
target/
4+
*.md
5+
.gitignore
6+
.idea/
7+
*.iml
8+
.vscode/
9+
.DS_Store
10+
docker-compose*.yml

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Stage 1 - Build
2+
FROM eclipse-temurin:21-jdk-alpine AS build
3+
4+
WORKDIR /app
5+
6+
COPY mvnw .
7+
COPY .mvn .mvn
8+
COPY pom.xml .
9+
10+
RUN chmod +x mvnw && ./mvnw dependency:go-offline -B
11+
12+
COPY src src
13+
14+
RUN ./mvnw clean package -DskipTests -B
15+
16+
# Stage 2 - Runtime
17+
FROM eclipse-temurin:21-jre-alpine AS runtime
18+
19+
LABEL maintainer="felipementel" \
20+
description="CRUD de usuarios em Spring Boot com Ports and Adapters"
21+
22+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
23+
24+
WORKDIR /app
25+
26+
COPY --from=build /app/target/*.jar app.jar
27+
28+
RUN chown appuser:appgroup app.jar
29+
30+
USER appuser
31+
32+
EXPOSE 8080
33+
34+
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
35+
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health/ready || exit 1
36+
37+
ENTRYPOINT ["java", "-jar", "app.jar"]

0 commit comments

Comments
 (0)