-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
71 lines (68 loc) · 2.15 KB
/
docker-compose.prod.yml
File metadata and controls
71 lines (68 loc) · 2.15 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
services:
db:
image: postgres:${POSTGRES_VERSION:-17}
restart: unless-stopped
environment:
POSTGRES_USER: ${DB_USER:-javabin}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME:-javabinkids}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-javabin} -d ${DB_NAME:-javabinkids}"]
interval: 10s
timeout: 5s
retries: 5
app:
image: ghcr.io/javabin/javabinkids:${JZ_KIDS_VERSION:-latest}
restart: unless-stopped
ports:
- "${APP_PORT:-3000}:3000"
environment:
DATABASE_URL: postgres://${DB_USER:-javabin}:${DB_PASSWORD}@db:5432/${DB_NAME:-javabinkids}
RESEND_API_KEY: ${RESEND_API_KEY}
BASE_URL: ${BASE_URL}
NODE_ENV: production
depends_on:
db:
condition: service_healthy
backup:
image: postgres:${POSTGRES_VERSION:-17}
restart: unless-stopped
environment:
PGHOST: db
PGUSER: ${DB_USER:-javabin}
PGPASSWORD: ${DB_PASSWORD}
PGDATABASE: ${DB_NAME:-javabinkids}
BACKUP_KEEP_DAYS: ${BACKUP_KEEP_DAYS:-30}
volumes:
- backups:/backups
entrypoint: ["/bin/bash", "-c"]
command:
- |
echo "Backup service started. Running daily at 03:00."
while true; do
NOW=$$(date +%H%M)
if [ "$$NOW" = "0300" ]; then
TIMESTAMP=$$(date +%Y%m%d-%H%M%S)
FILENAME="javabinkids-$$TIMESTAMP.sql.gz"
echo "[$$TIMESTAMP] Starting backup..."
pg_dump | gzip > /backups/$$FILENAME
if [ $$? -eq 0 ]; then
echo "[$$TIMESTAMP] Backup saved: $$FILENAME ($$(du -h /backups/$$FILENAME | cut -f1))"
else
echo "[$$TIMESTAMP] ERROR: Backup failed!"
fi
find /backups -name "javabinkids-*.sql.gz" -mtime +$$BACKUP_KEEP_DAYS -delete
echo "[$$TIMESTAMP] Cleanup done. Current backups:"
ls -lh /backups/javabinkids-*.sql.gz 2>/dev/null || echo " (none)"
sleep 60
fi
sleep 50
done
depends_on:
db:
condition: service_healthy
volumes:
pgdata:
backups: