-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.postgres.yml
More file actions
119 lines (112 loc) · 4.28 KB
/
Copy pathdocker-compose.postgres.yml
File metadata and controls
119 lines (112 loc) · 4.28 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
115
116
117
118
119
# Glyph — Postgres overlay (local development)
#
# Layer this over the base file to add the Go API, Postgres, migrations,
# and an Nginx reverse proxy — all with live reload.
#
# docker compose -f docker-compose.yml -f docker-compose.postgres.yml up
#
# Migrations run automatically before the API starts.
# Frontend: https://localhost (via Nginx) with Vite HMR
# Go API: rebuilt on save via Air
services:
# ─── Override frontend → API storage mode ──────────────────────────────────
app:
environment:
- VITE_STORAGE_MODE=api
- VITE_API_URL=
- API_PROXY_TARGET=http://api:8080
- COLLAB_PROXY_TARGET=http://collab:1235
# ─── Nginx reverse proxy ──────────────────────────────────────────────────
nginx:
build: ./nginx
ports:
- "443:443"
- "80:80"
depends_on:
- app
- api
- collab
# ─── Postgres ──────────────────────────────────────────────────────────────
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-glyph}
POSTGRES_USER: ${POSTGRES_USER:-glyph}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-glyph}
ports:
- "127.0.0.1:5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U glyph"]
interval: 5s
timeout: 5s
retries: 5
# ─── DB migrations (run once then exit) ────────────────────────────────────
migrate:
image: migrate/migrate:latest
depends_on:
postgres:
condition: service_healthy
volumes:
- ./api/migrations:/migrations
command:
- "-path=/migrations"
- "-database"
- "postgres://${POSTGRES_USER:-glyph}:${POSTGRES_PASSWORD:-glyph}@postgres:5432/${POSTGRES_DB:-glyph}?sslmode=disable"
- "up"
restart: "no"
# ─── Go API with Air hot-reload ────────────────────────────────────────────
api:
build:
context: ./api
dockerfile: Dockerfile.dev
volumes:
- ./api:/app
expose:
- "8080"
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
env_file:
- path: ./api/.env
required: false
environment:
DATABASE_URL: postgres://${POSTGRES_USER:-glyph}:${POSTGRES_PASSWORD:-glyph}@postgres:5432/${POSTGRES_DB:-glyph}?sslmode=disable
PORT: "8080"
# Realtime collaborative editing. Set COLLAB_ENABLED=false to fall back
# to single-writer editing.
COLLAB_ENABLED: ${COLLAB_ENABLED:-true}
COLLAB_SERVICE_TOKEN: ${COLLAB_SERVICE_TOKEN:-dev-collab-service-token}
# ─── Collab service (Hocuspocus), rebuilt on save ──────────────────────────
collab:
image: node:22-alpine
working_dir: /repo
volumes:
- .:/repo
- collab_node_modules:/repo/node_modules
# Install, build once, then rebuild on save (esbuild --watch in the
# background) and restart the server whenever the bundle changes.
command: >
sh -c "corepack enable && corepack prepare pnpm@10 --activate &&
pnpm install --frozen-lockfile --ignore-scripts &&
pnpm --filter @k5s/glyph-collab build &&
{ pnpm --filter @k5s/glyph-collab dev & } &&
exec node --watch-path=collab/dist --enable-source-maps collab/dist/server.js"
expose:
- "1235"
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
environment:
DATABASE_URL: postgres://${POSTGRES_USER:-glyph}:${POSTGRES_PASSWORD:-glyph}@postgres:5432/${POSTGRES_DB:-glyph}?sslmode=disable
API_URL: http://api:8080
COLLAB_SERVICE_TOKEN: ${COLLAB_SERVICE_TOKEN:-dev-collab-service-token}
PORT: "1235"
volumes:
collab_node_modules:
postgres_data: