Repository navigation
Expand file tree
/
Copy pathcompose.yml
More file actions
60 lines (55 loc) · 1.5 KB
/
Copy pathcompose.yml
File metadata and controls
60 lines (55 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
services:
# Database service
db:
image: 'postgres:15.2-alpine'
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
volumes:
- restjpa-pg-data:/var/lib/postgresql/data
networks:
- backend
healthcheck: # Adding healthcheck for better orchestration
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
interval: 10s
timeout: 5s
retries: 5
# Application service
app:
image: 'docker.io/brunoe/restjpa:0.1.0'
build:
context: .
dockerfile: Dockerfile
depends_on:
db:
condition: service_healthy # Wait for db to be healthy before starting
environment:
- MAVEN_PROFILE=prod
- DB_URL=jdbc:postgresql://db:5432/${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_SCHEMA_ACTION=${DB_SCHEMA_ACTION}
- DB_MAX_POOL=${DB_MAX_POOL}
- DB_MIN_IDLE=${DB_MIN_IDLE}
ports:
- "8088:8080"
networks:
- frontend
- backend
restart: unless-stopped # Adding restart policy for better reliability
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/restjpa/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
# Named volumes for persistent data
volumes:
restjpa-pg-data:
name: restjpa-pg-data # Explicit naming for better management
# Network configuration
networks:
frontend:
name: restjpa-frontend
backend:
name: restjpa-backend