dockerized atproto relay
1# Dockerized AT Protocol Relay
2
3Heavily ~~copy and pasted~~ influenced by [phil's relay configurations](https://gist.github.com/futurGH/2ee18d385eff3ba98f5b35b9dcac0aed#file-docker-compose-yaml-L1) and [futur.blue's whitewind blog post](https://whtwnd.com/futur.blue/3lkubavdilf2m)
4
5## Setup
6
7clone this repo and change directory into it
8
9```bash
10git clone git@tangled.sh:dane.is.extraordinarily.cool/relay-docker
11
12cd relay-docker
13```
14
15clone the indigo repo
16
17```bash
18git clone git@github.com:bluesky-social/indigo.git
19```
20
21rename the `.env.example` file to just `.env`
22
23```bash
24mv .env.example .env
25```
26
27add values for these env variables, see [configuration and operation](https://github.com/bluesky-social/indigo/blob/main/cmd/relay/README.md#configuration-and-operation) section in the indigo repo to understand what the values mean
28
29```bash
30RELAY_LENIENT_SYNC_VALIDATION=true
31RELAY_REPLAY_WINDOW=48h
32RELAY_PERSIST_DIR=/data/relay/persist
33RELAY_ADMIN_PASSWORD=
34RELAY_TRUSTED_DOMAINS=
35RELAY_HOST_CONCURRENCY=4
36
37# database env
38DATABASE_URL=
39POSTGRES_USER=
40POSTGRES_PASSWORD=
41POSTGRES_DB=
42```
43
44update the caddy file to point to your domain (make sure you have set up the necessary dns records)
45
46```bash
47// conf/Caddyfile
48
49yourdomain.com {
50 tls {
51 on_demand
52 }
53
54 handle /xrpc/com.atproto.sync.subscribeRepos {
55 reverse_proxy 127.0.0.1:2470 {
56 header_up Origin "yourdomain.com"
57 }
58 }
59
60 reverse_proxy localhost:2470
61}
62```
63
64if you wanted to just test things out you can use something like ngrok
65
66```bash
67ngrok http 2470
68```
69
70then just take whatever domain is generated for you and add it to the caddyfile
71
72start the relay
73
74```bash
75docker compose up -d
76```
77
78verify that it is running
79
80```bash
81curl localhost:2470
82```
83
84## PDS Crawling
85
86see [bootstrapping host list](https://github.com/bluesky-social/indigo/blob/main/cmd/relay/README.md#bootstrapping-host-list) and the [how to do it](https://whtwnd.com/futur.blue/3lkubavdilf2m) section in futur's blog post to see how to bootstrap your relay with pdses
87
88for convenience, I've included a `pull-hosts.sh` that pulls a list of pdses based on [mary's pds scraper script](https://raw.githubusercontent.com/mary-ext/atproto-scraping/refs/heads/trunk/state.json)
89
90you can write whatever script you want to do the requestCrawl to the pdes but the easiest way is probably [installing and using `goat`](https://github.com/bluesky-social/indigo/tree/main/cmd/goat#install)
91
92make the script executable and run it and redirect the output to a text file
93
94```bash
95chmod u+x pull-hosts.sh
96
97./pull-hosts > hosts.txt
98```
99
100we can then use `goat` to add hosts to the relay
101
102```bash
103shuf hosts.txt | RELAY_HOST=http://localhost:2470 parallel goat relay admin host add {}
104```