-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
114 lines (107 loc) · 3.88 KB
/
Copy pathdocker-compose.yml
File metadata and controls
114 lines (107 loc) · 3.88 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# docker-compose.yml
#
# Runs the full VaultTabs stack with one command:
# docker compose up
#
# Services:
# postgres → Database (port 5432)
# backend → Fastify API (port 3000)
# pwa → Next.js PWA (port 3001)
#
# Production mode:
# docker compose -f docker-compose.yml -f docker-compose.prod.yml up
#
# First-time setup:
# 1. Copy .env.example to .env and fill in values
# 2. docker compose up
# 3. docker compose exec backend npm run db:migrate
version: '3.9'
services:
# ── PostgreSQL ──────────────────────────────────────────────────────────────
postgres:
image: postgres:16-alpine
container_name: vaulttabs-postgres
restart: unless-stopped
environment:
POSTGRES_DB: vaulttabs
POSTGRES_USER: vaulttabs
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-localdevpassword}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
# Run init SQL on first startup
- ./docker/postgres-init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: CMD-SHELL pg_isready -U vaulttabs -d vaulttabs
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
# ── Backend (Fastify) ───────────────────────────────────────────────────────
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: vaulttabs-backend
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
NODE_ENV: development
PORT: 3000
DATABASE_URL: postgres://vaulttabs:${POSTGRES_PASSWORD:-localdevpassword}@postgres:5432/vaulttabs
JWT_SECRET: "${JWT_SECRET:?JWT_SECRET is required - run: node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"}"
JWT_EXPIRY: ${JWT_EXPIRY:-30d}
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:3001}
ports:
- "3000:3000"
volumes:
# Hot reload in dev: mount source, not just the build
- ./backend/src:/app/src:ro
healthcheck:
test: CMD-SHELL wget -qO- http://localhost:3000/health || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
# ── PWA (Next.js) ───────────────────────────────────────────────────────────
pwa:
build:
context: ./pwa
dockerfile: Dockerfile
container_name: vaulttabs-pwa
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3000/api/v1}
ports:
- "3001:3001"
healthcheck:
test: CMD-SHELL wget -qO- http://localhost:3001 || exit 1
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
# ── Cleanup job (runs every hour) ──────────────────────────────────────────
# Expires old restore_requests and enforces snapshot retention limits.
# Uses the same backend image — just runs a different command.
cleanup:
build:
context: ./backend
dockerfile: Dockerfile
container_name: vaulttabs-cleanup
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: postgres://vaulttabs:${POSTGRES_PASSWORD:-localdevpassword}@postgres:5432/vaulttabs
command: ["sh", "-c", "while true; do node dist/db/cleanup.js; sleep 3600; done"]
volumes:
postgres_data:
driver: local