Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
45 lines (43 loc) · 1.49 KB
/
Copy pathdocker-compose.yml
File metadata and controls
45 lines (43 loc) · 1.49 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
services:
postgres:
image: postgres:16-alpine
container_name: postgrest-db
environment:
- POSTGRES_DB=${POSTGRES_DB:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./config/init.sql:/init.sql
command: >
bash -c "docker-entrypoint.sh postgres &
until pg_isready -U ${POSTGRES_USER:-postgres}; do sleep 1; done;
psql -U ${POSTGRES_USER:-postgres} -tAc \"SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'todos');\" | grep -q t || psql -U ${POSTGRES_USER:-postgres} -f /init.sql;
wait"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
postgrest:
build:
context: .
dockerfile: Dockerfile
container_name: postgrest-app
ports:
- "3000:3000"
environment:
- PGRST_DB_URI=${PGRST_DB_URI:-postgres://postgres:postgres@postgres:5432/postgres}
- PGRST_DB_SCHEMAS=${PGRST_DB_SCHEMAS:-public}
- PGRST_DB_ANON_ROLE=${PGRST_DB_ANON_ROLE:-postgres}
- PGRST_SERVER_HOST=${PGRST_SERVER_HOST:-0.0.0.0}
- PGRST_SERVER_PORT=${PGRST_SERVER_PORT:-3000}
- PGRST_LOG_LEVEL=${PGRST_LOG_LEVEL:-info}
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
volumes:
postgres_data: