Skip to content

Commit ec97f18

Browse files
committed
feat: update Docker configurations and application properties for improved health checks and service management
1 parent 4e40273 commit ec97f18

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.gitignore

37 Bytes
Binary file not shown.

docker-compose.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: '3.8'
2+
13
services:
24
# Place Eureka server first with healthcheck
35
eureka-server:
@@ -11,11 +13,12 @@ services:
1113
- SPRING_PROFILES_ACTIVE=docker
1214
- SERVER_PORT=8761
1315
healthcheck:
14-
test: ["CMD-SHELL", "curl -f http://localhost:8761/actuator/health || exit 1"]
15-
interval: 10s
16+
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8761/actuator/health"]
17+
interval: 30s
1618
timeout: 5s
17-
retries: 10
18-
start_period: 30s
19+
retries: 3
20+
start_period: 60s
21+
restart: unless-stopped
1922

2023
# API Gateway depends on healthy Eureka server
2124
api-gateway:

eureka-server/src/main/resources/application.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ spring:
99

1010
eureka:
1111
client:
12-
register-with-eureka: false
13-
fetch-registry: false
12+
registerWithEureka: false
13+
fetchRegistry: false
1414
server:
1515
wait-time-in-ms-when-sync-empty: 0
1616

1717
management:
1818
endpoints:
1919
web:
2020
exposure:
21-
include: health,info,metrics
21+
include: health
2222
base-path: /actuator
2323
endpoint:
2424
health:

vm-deploy/eureka-server/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ COPY --from=builder /app/app.jar /app.jar
2020

2121
# Create non-root user
2222
RUN addgroup -S spring && adduser -S spring -G spring
23-
USER spring:spring
23+
24+
# Install wget for health check
25+
RUN apk add --no-cache wget
2426

2527
# Configure health check
26-
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
28+
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
2729
CMD wget -q --spider http://localhost:8761/actuator/health || exit 1
2830

2931
EXPOSE 8761
32+
33+
USER spring:spring
3034
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-jar", "/app.jar"]

0 commit comments

Comments
 (0)