Repository navigation
Expand file tree
/
Copy pathcompose.dev.yml
More file actions
208 lines (201 loc) · 8.69 KB
/
Copy pathcompose.dev.yml
File metadata and controls
208 lines (201 loc) · 8.69 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Development stack for downradar.info.
#
# Everything runs in Docker: Postgres, Redis, Mailpit, the Go API with hot
# reload, and the Nuxt dev server with HMR. `make dev` starts all of it.
name: downradar
services:
db:
image: postgres:18
container_name: downradar-db
environment:
POSTGRES_USER: ${POSTGRES_USER:-downradar}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-downradar}
POSTGRES_DB: ${POSTGRES_DB:-downradar}
ports:
- "5433:5432"
volumes:
# postgres:18 sets PGDATA=/var/lib/postgresql/18/docker and declares
# VOLUME /var/lib/postgresql. Mounting at /var/lib/postgresql/data
# (as in older images) creates an anonymous volume instead, and the
# data is lost on `docker compose down`.
- db-data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U downradar -d downradar"]
interval: 3s
timeout: 3s
retries: 30
redis:
image: redis:8-alpine
container_name: downradar-redis
ports:
# 6380 on the host, because 6379 is often already taken by a Redis
# running for something else on the same machine.
- "6380:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 3s
timeout: 3s
retries: 20
mailpit:
image: axllent/mailpit:latest
container_name: downradar-mailpit
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
ports:
- "1026:1025" # SMTP
- "8026:8025" # web UI at http://localhost:8026
api:
build:
context: ./backend
dockerfile: Dockerfile.dev
container_name: downradar-api
depends_on:
db:
condition: service_healthy
mailpit:
condition: service_started
environment:
DATABASE_URL: postgres://${POSTGRES_USER:-downradar}:${POSTGRES_PASSWORD:-downradar}@db:5432/${POSTGRES_DB:-downradar}?sslmode=disable
# The application's own cache and ephemeral state. Nothing reads it yet;
# the address is here so the code that starts to can.
REDIS_URL: redis://redis:6379/0
HTTP_ADDR: ":8080"
SERVICES_FILE: /etc/downradar/services.yaml
POLL_CONCURRENCY: "8"
POLL_TICK: 5s
LOG_LEVEL: info
# Both API endpoints are public, so anonymous callers are rate limited per
# IP. The frontend proves it is not a third party by sending this token,
# which the Nitro proxy adds to every /api/v1/** request it forwards.
INTERNAL_TOKEN: ${INTERNAL_TOKEN:-}
RATE_LIMIT_PER_MINUTE: ${RATE_LIMIT_PER_MINUTE:-120}
RATE_LIMIT_BURST: ${RATE_LIMIT_BURST:-30}
SUGGEST_RATE_LIMIT_PER_HOUR: ${SUGGEST_RATE_LIMIT_PER_HOUR:-6}
SUGGEST_RATE_LIMIT_BURST: ${SUGGEST_RATE_LIMIT_BURST:-5}
# The dev site is served over plain http on localhost, so a Secure cookie
# would be dropped by the browser and signing in would silently fail.
SESSION_COOKIE_SECURE: "false"
SESSION_COOKIE: ${SESSION_COOKIE:-dr_session}
SESSION_TTL: ${SESSION_TTL:-720h}
LOGIN_RATE_LIMIT_PER_HOUR: ${LOGIN_RATE_LIMIT_PER_HOUR:-20}
LOGIN_RATE_LIMIT_BURST: ${LOGIN_RATE_LIMIT_BURST:-5}
PASSWORD_RATE_LIMIT_PER_HOUR: ${PASSWORD_RATE_LIMIT_PER_HOUR:-20}
PASSWORD_RATE_LIMIT_BURST: ${PASSWORD_RATE_LIMIT_BURST:-5}
LINK_RATE_LIMIT_PER_HOUR: ${LINK_RATE_LIMIT_PER_HOUR:-6}
LINK_RATE_LIMIT_BURST: ${LINK_RATE_LIMIT_BURST:-5}
RAW_PAYLOAD_MIN_INTERVAL: ${RAW_PAYLOAD_MIN_INTERVAL:-1h}
RAW_PAYLOAD_RETENTION_DAYS: ${RAW_PAYLOAD_RETENTION_DAYS:-7}
# Alerts go out over SMTP. Mailpit catches them in development and shows
# them at http://localhost:8026. Without SMTP_ADDR the feature is off: the
# API refuses subscriptions rather than taking them and sending nothing.
SMTP_ADDR: ${SMTP_ADDR:-mailpit:1025}
# Seals the secrets the database keeps. Required while alerts are on; the
# same value has to survive a restart or the saved values cannot be read
# again.
APP_KEY: ${APP_KEY:-}
# Mailpit takes mail without a login, so both stay empty locally. They are
# here so a real server can be pointed at without touching this file.
SMTP_USER: ${SMTP_USER:-}
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
MAIL_FROM: ${MAIL_FROM:-DownRadar <alerts@downradar.test>}
# A Bot API server to talk to, for a self-hosted bot or for trying this
# without a real one. Empty means Telegram itself. The bots are the
# subscribers' own, so no token is configured here.
TELEGRAM_API_BASE: ${TELEGRAM_API_BASE:-}
# A background sender has no request to read the site address from, so the
# links it writes into an email come from here.
PUBLIC_URL: ${PUBLIC_URL:-http://localhost:3000}
# Signing in with GitHub. Both halves are needed: without them the button
# is not offered and the routes say the provider is not configured. The
# callback registered with GitHub is PUBLIC_URL plus
# /api/v1/auth/github/callback.
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET:-}
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET:-}
# Adding a Slack channel in one click installs the site's own Slack app.
# The callback registered with it is PUBLIC_URL plus
# /api/v1/slack/callback.
SLACK_CLIENT_ID: ${SLACK_CLIENT_ID:-}
SLACK_CLIENT_SECRET: ${SLACK_CLIENT_SECRET:-}
# Adding a Discord channel in one click uses the site's Discord app and
# its webhook.incoming scope. The callback is PUBLIC_URL plus
# /api/v1/discord/callback.
DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID:-}
DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET:-}
ALERT_SEND_INTERVAL: ${ALERT_SEND_INTERVAL:-5s}
ALERT_RATE_LIMIT_PER_HOUR: ${ALERT_RATE_LIMIT_PER_HOUR:-6}
ALERT_RATE_LIMIT_BURST: ${ALERT_RATE_LIMIT_BURST:-5}
ALERT_TEST_RATE_LIMIT_PER_HOUR: ${ALERT_TEST_RATE_LIMIT_PER_HOUR:-60}
ALERT_TEST_RATE_LIMIT_BURST: ${ALERT_TEST_RATE_LIMIT_BURST:-10}
# The generated sentence above a vendor's incidents. All four values are
# required; the key belongs in .env and is never committed. The switch
# turns it off even while the values are set, and also hides a stored
# sentence.
SUMMARY_ENABLED: ${SUMMARY_ENABLED:-true}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
OPENAI_MODEL: ${OPENAI_MODEL:-}
OPENAI_BASE_URL: ${OPENAI_BASE_URL:-}
OPENAI_TIMEOUT: ${OPENAI_TIMEOUT:-}
ports:
- "8080:8080"
volumes:
- ./backend:/app
# The vendor registry lives at the repository root so it is easy to
# find. It is mounted OUTSIDE /app on purpose: mounting it inside the
# backend bind mount makes Docker create the mountpoint on the host,
# which leaves a stray empty backend/services.yaml behind.
# The profiles are read once at startup, so a change here needs
# `make restart-api`. If the file was replaced rather than edited, the
# mount still points at the old inode and the container has to be
# recreated instead.
- ./services.yaml:/etc/downradar/services.yaml:ro
# The bootstrap file is only read by the seed command and its tests.
- ./seed:/app/seed:ro
- go-mod-cache:/go/pkg/mod
- go-build-cache:/root/.cache/go-build
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080/healthz"]
interval: 5s
timeout: 3s
retries: 30
web:
build:
context: ./frontend
dockerfile: Dockerfile.dev
container_name: downradar-web
depends_on:
- api
environment:
# The proxy target for /api/v1/**, see server/middleware/api-proxy.ts.
NUXT_API_BASE: http://api:8080
NUXT_TELEMETRY_DISABLED: "1"
NUXT_PUBLIC_SITE_URL: ${NUXT_PUBLIC_SITE_URL:-http://localhost:3000}
NUXT_PAGE_CACHE_SECONDS: ${NUXT_PAGE_CACHE_SECONDS:-60}
# Sent as X-Internal-Token by the proxy, so the API knows this traffic is
# ours.
INTERNAL_TOKEN: ${INTERNAL_TOKEN:-}
# Nitro reads runtime config from NUXT_* variables, not from the names the
# Go API uses, so the same secret is exposed under both names.
NUXT_INTERNAL_TOKEN: ${INTERNAL_TOKEN:-}
# Public on purpose: rendered as a link in the footer.
NUXT_PUBLIC_GITHUB_REPO: ${GITHUB_REPO:-}
ports:
- "3000:3000"
volumes:
- ./frontend:/app
# Named volumes keep dependencies and build output out of the host
# filesystem, which avoids permission and performance surprises on
# bind mounts.
- web-node-modules:/app/node_modules
- web-nuxt:/app/.nuxt
volumes:
db-data:
redis-data:
go-mod-cache:
go-build-cache:
web-node-modules:
web-nuxt: