Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
157 lines (145 loc) · 5.28 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
157 lines (145 loc) · 5.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: freenary
x-app-build: &app-build
context: .
dockerfile: .docker/dockerfile.dev
x-app-watch: &app-watch
- action: sync
path: ./apps
target: /app/apps
ignore:
- node_modules/
# Generated on each side by the paraglide compile step: syncing the host
# copy over the container's deletes it mid-session, and Vite caches the
# failed resolution of `@/paraglide/server.js` into a permanent 500.
- web/src/paraglide/
- action: sync
path: ./packages
target: /app/packages
ignore:
- node_modules/
- action: rebuild
path: ./bun.lock
# The root .env file is optional, and every variable a contributor sets in it
# reaches the containers through it. Only the values this stack derives from the
# worktree are listed below, and `environment` wins over `env_file`.
x-app-env-file: &app-env-file
- path: .env
required: false
x-app-env: &app-env
DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-freenary}
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:-dev_secret_change_me_at_least_32chars}
# The shared devproxy Traefik serves every *.localhost name over plain HTTP.
# Browsers treat *.localhost as a secure context, and web and server share the
# parent domain in AUTH_COOKIE_DOMAIN, so a Lax cookie reaches both.
BETTER_AUTH_URL: http://${SERVER_HOST:-server.freenary.localhost}
CORS_ORIGIN: http://${WEB_HOST:-web.freenary.localhost}
AUTH_COOKIE_DOMAIN: ${AUTH_COOKIE_DOMAIN:-}
NODE_ENV: development
# Joined by every service the browser reaches. `devproxy` is the network of the
# shared Traefik that `scripts/dev.ts` starts or reuses; the stack's own
# default network keeps postgres off it.
x-proxied: &proxied
- default
- devproxy
services:
postgres:
image: postgres:18-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-freenary}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
expose:
- "${POSTGRES_PORT:-5432}"
volumes:
- pgdata:/var/lib/postgresql
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-freenary}",
]
interval: 5s
timeout: 5s
retries: 10
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.
bootstrap:
build: *app-build
working_dir: /app/packages/db
command: bun x prisma migrate deploy
environment:
DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-freenary}
depends_on:
postgres:
condition: service_healthy
server:
build: *app-build
working_dir: /app/apps/server
command: bun run --hot src/index.ts
env_file: *app-env-file
environment:
<<: *app-env
# Compose also registers `server` on devproxy, where every worktree's API
# answers to it. In-stack callers use this alias, which only the stack's
# own default network knows.
networks:
default:
aliases: [freenary-server]
devproxy: {}
labels:
- traefik.enable=true
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-server.rule=Host(`${SERVER_HOST:-server.freenary.localhost}`)
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-server.entrypoints=web
- traefik.http.services.freenary-${FREENARY_SLUG:-dev}-server.loadbalancer.server.port=3000
develop:
watch: *app-watch
depends_on:
postgres:
condition: service_healthy
bootstrap:
condition: service_completed_successfully
restart: unless-stopped
web:
build: *app-build
working_dir: /app/apps/web
command: bun run dev -- --host 0.0.0.0
environment:
VITE_SERVER_URL: http://${SERVER_HOST:-server.freenary.localhost}
# What the web app's own server calls while rendering a page: the
# container network, since `*.localhost` resolves to the container itself.
SERVER_URL: ${SERVER_URL:-http://freenary-server:3000}
DEV_PUBLIC_URL: http://${WEB_HOST:-web.freenary.localhost}
networks: *proxied
labels:
- traefik.enable=true
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-web.rule=Host(`${WEB_HOST:-web.freenary.localhost}`)
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-web.entrypoints=web
- traefik.http.services.freenary-${FREENARY_SLUG:-dev}-web.loadbalancer.server.port=3001
develop:
watch: *app-watch
depends_on:
- server
restart: unless-stopped
docs:
build: *app-build
working_dir: /app/apps/fumadocs
command: bun run dev -- --host 0.0.0.0
environment:
DOCS_PORT: ${DOCS_PORT:-4000}
DEV_PUBLIC_URL: http://${DOCS_HOST:-docs.freenary.localhost}
networks: *proxied
labels:
- traefik.enable=true
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-docs.rule=Host(`${DOCS_HOST:-docs.freenary.localhost}`)
- traefik.http.routers.freenary-${FREENARY_SLUG:-dev}-docs.entrypoints=web
- traefik.http.services.freenary-${FREENARY_SLUG:-dev}-docs.loadbalancer.server.port=4000
develop:
watch: *app-watch
restart: unless-stopped
volumes:
pgdata:
networks:
devproxy:
name: devproxy
external: true