Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
102 lines (94 loc) · 3.13 KB
/
Copy pathdocker-compose.yml
File metadata and controls
102 lines (94 loc) · 3.13 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
name: freenary
# The self-hosted stack, from the published images. `docker compose up -d`
# pulls them, applies the database migrations and starts everything.
# Every setting comes from the `.env` file next to this file; `.env.example`
# lists them. To run your own build instead, replace each `image:` with
# `build: { context: ., dockerfile: apps/<app>/Dockerfile }`.
x-server-image: &server-image ghcr.io/suiramdev/freenary-server:${FREENARY_VERSION:-latest}
x-database-url: &database-url postgresql://postgres:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/freenary
services:
postgres:
image: postgres:18
environment:
POSTGRES_DB: freenary
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
# Loopback only: for backups and `bun run db:*` from the host, never the network.
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes:
- freenary_postgres_data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d freenary"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# One-shot: applies pending migrations before the server starts.
# Re-runs on every `up` (idempotent); exits 0 when the schema is current.
migrate:
image: *server-image
working_dir: /app/packages/db
command: bun x prisma migrate deploy
environment:
DATABASE_URL: *database-url
depends_on:
postgres:
condition: service_healthy
server:
image: *server-image
init: true
env_file: .env
environment:
DATABASE_URL: *database-url
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?Set BETTER_AUTH_SECRET in .env}
BETTER_AUTH_URL: ${BETTER_AUTH_URL:-http://localhost:3001}
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:3001}
NODE_ENV: production
healthcheck:
test:
[
"CMD",
"bun",
"-e",
"fetch('http://localhost:3000/').then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
restart: unless-stopped
web:
image: ghcr.io/suiramdev/freenary-web:${FREENARY_VERSION:-latest}
init: true
ports:
- "${WEB_PORT:-3001}:3001"
environment:
# What the web app's own server calls while rendering a page.
SERVER_URL: http://server:3000
# What the browser calls: the public API origin, same as BETTER_AUTH_URL.
PUBLIC_SERVER_URL: ${BETTER_AUTH_URL:-http://localhost:3001}
TRUSTED_PROXIES: ${TRUSTED_PROXIES:-}
healthcheck:
test:
[
"CMD",
"bun",
"-e",
"fetch('http://localhost:3001/').then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
server:
condition: service_healthy
restart: unless-stopped
volumes:
freenary_postgres_data: