Skip to content

Commit 6753150

Browse files
feat: add health check in echo sql compose db (#176)
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent c1aaacb commit 6753150

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

echo-sql/docker-compose.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@ services:
77
ports:
88
- "8082:8082"
99
depends_on:
10-
- postgres
10+
postgres:
11+
condition: service_healthy
1112
networks:
1213
- babab
1314

1415
postgres:
15-
image: postgres:10.5
16-
container_name: postgresDb
17-
restart: always
18-
environment:
19-
- POSTGRES_DB=postgres
20-
- POSTGRES_USER=postgres
21-
- POSTGRES_PASSWORD=password
22-
ports:
23-
- '5432:5432'
24-
volumes:
25-
# - ./postgres-data:/var/lib/postgresql/data
26-
# copy the sql script to create tables
27-
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql
28-
networks:
29-
- babab
16+
image: postgres:10.5
17+
container_name: postgresDb
18+
restart: always
19+
environment:
20+
- POSTGRES_DB=postgres
21+
- POSTGRES_USER=postgres
22+
- POSTGRES_PASSWORD=password
23+
ports:
24+
- '5432:5432'
25+
volumes:
26+
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql
27+
networks:
28+
- babab
29+
healthcheck:
30+
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
31+
interval: 5s
32+
timeout: 5s
33+
retries: 5
34+
start_period: 30s
3035

3136
networks:
3237
babab:

0 commit comments

Comments
 (0)