-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
68 lines (65 loc) · 1.8 KB
/
docker-compose.yml
File metadata and controls
68 lines (65 loc) · 1.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
services:
db:
image: postgres:16
environment:
POSTGRES_USER: workspace
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: workspace
volumes:
- workspace_db:/var/lib/postgresql/data
- ./backups:/backups
healthcheck:
test: ["CMD-SHELL", "pg_isready -U workspace"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
api:
build: ./packages/workspace-api
environment:
PORT: 8080
DB_URL: postgres://workspace:${DB_PASSWORD}@db:5432/workspace
WORKSPACE_SERVICE_TOKEN: ${WORKSPACE_SERVICE_TOKEN}
FILES_DIR: /data/files
volumes:
- workspace_files:/data/files
depends_on:
db:
condition: service_healthy
ports:
- "8082:8080"
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
restart: unless-stopped
backup:
image: postgres:16
environment:
PGPASSWORD: ${DB_PASSWORD}
volumes:
- ./backups:/backups
depends_on:
db:
condition: service_healthy
entrypoint: >
sh -c '
echo "Workspace DB backup cron — runs daily at 3 AM UTC"
while true; do
STAMP=$$(date +%Y%m%d_%H%M%S)
echo "[$$STAMP] Starting backup..."
pg_dump -h db -U workspace workspace | gzip > /backups/workspace_$$STAMP.sql.gz
echo "[$$STAMP] Backup complete: workspace_$$STAMP.sql.gz"
# Keep only the last 7 backups
ls -1t /backups/workspace_*.sql.gz 2>/dev/null | tail -n +8 | xargs rm -f 2>/dev/null
echo "[$$STAMP] Sleeping 24h..."
sleep 86400
done
'
restart: unless-stopped
volumes:
workspace_db:
workspace_files: