-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
80 lines (77 loc) · 2.8 KB
/
Copy pathdocker-compose.yml
File metadata and controls
80 lines (77 loc) · 2.8 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Demo setup for pg_timetable
#
# Loaded sample chains (all self-contained, no external dependencies):
# 01 Basic.sql — pg_notify every minute
# 02 CronStyle.sql — cron expression scheduling demo
# 03 Chain.sql — multi-task chain with shared log table
# 04 ErrorHandling.sql — division-by-zero with on_error notification
# 05 Log.sql — built-in Log task
# 06 NoOp.sql — built-in NoOp task
# 07 Sleep.sql — built-in Sleep task (@every 10 seconds)
# 08 Autonomous.sql — autonomous task with mid-chain COMMITs
# 09 Exclusive.sql — exclusive execution lock demo
# 10 DelayedRetry.sql — retry with back-off on failure
# 11 SelfDestruct.sql — chain that removes itself after one run
# 12 ClientMessages.sql — LISTEN/NOTIFY between client and scheduler
#
# Usage:
# docker compose up — start PostgreSQL + pg_timetable
# docker compose up --build — rebuild pg_timetable image first
# docker compose down -v — stop and remove all volumes
services:
postgres:
image: postgres:18-alpine
container_name: pg_timetable_db
restart: unless-stopped
environment:
POSTGRES_DB: timetable
POSTGRES_USER: scheduler
POSTGRES_PASSWORD: scheduler_password
ports:
- "5432:5432"
volumes:
# postgres 18+ requires the volume at /var/lib/postgresql (not /data)
- pg_data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U scheduler -d timetable"]
interval: 5s
timeout: 5s
retries: 10
pg_timetable:
build:
context: .
dockerfile: Dockerfile
container_name: pg_timetable_app
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
# Full connection string — the only supported connection env var
PGTT_CONNSTR: "host=postgres port=5432 dbname=timetable user=scheduler password=scheduler_password sslmode=disable"
# REST API port
PGTT_RESTPORT: "8008"
volumes:
# Sample files are loaded by pg_timetable after the schema is bootstrapped,
# so all timetable.* functions are already available when they run.
- ./samples/:/samples/:ro
ports:
- "8008:8008"
command:
- --clientname=demo_worker
- --upgrade
- --file=/samples/Basic.sql
- --file=/samples/CronStyle.sql
- --file=/samples/Chain.sql
- --file=/samples/ErrorHandling.sql
- --file=/samples/Log.sql
- --file=/samples/NoOp.sql
- --file=/samples/Sleep.sql
- --file=/samples/Autonomous.sql
- --file=/samples/Exclusive.sql
- --file=/samples/DelayedRetry.sql
- --file=/samples/SelfDestruct.sql
- --file=/samples/ClientMessages.sql
# - --log-level=debug
volumes:
pg_data: