···11# Dockerized AT Protocol Relay
2233-Heavily ~~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)
44-55-## Setup
66-77-clone this repo and change directory into it
88-99-```bash
1010-git clone git@tangled.sh:dane.is.extraordinarily.cool/relay-docker
1111-1212-cd relay-docker
1313-```
1414-1515-clone the indigo repo
1616-1717-```bash
1818-git clone git@github.com:bluesky-social/indigo.git
1919-```
2020-2121-rename the `.env.example` file to just `.env`
2222-2323-```bash
2424-mv .env.example .env
2525-```
2626-2727-add 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
2828-2929-```bash
3030-RELAY_LENIENT_SYNC_VALIDATION=true
3131-RELAY_REPLAY_WINDOW=48h
3232-RELAY_PERSIST_DIR=/data/relay/persist
3333-RELAY_ADMIN_PASSWORD=
3434-RELAY_TRUSTED_DOMAINS=
3535-RELAY_HOST_CONCURRENCY=4
3636-3737-# database env
3838-DATABASE_URL=
3939-POSTGRES_USER=
4040-POSTGRES_PASSWORD=
4141-POSTGRES_DB=
4242-```
4343-4444-update the caddy file to point to your domain (make sure you have set up the necessary dns records)
4545-4646-```bash
4747-// conf/Caddyfile
4848-4949-yourdomain.com {
5050- tls {
5151- on_demand
5252- }
5353-5454- handle /xrpc/com.atproto.sync.subscribeRepos {
5555- reverse_proxy 127.0.0.1:2470 {
5656- header_up Origin "yourdomain.com"
5757- }
5858- }
5959-6060- reverse_proxy localhost:2470
6161-}
6262-```
6363-6464-if you wanted to just test things out you can use something like ngrok
6565-6666-```bash
6767-ngrok http 2470
6868-```
6969-7070-then just take whatever domain is generated for you and add it to the caddyfile
7171-7272-start the relay
7373-7474-```bash
7575-docker compose up -d
7676-```
7777-7878-verify that it is running
7979-8080-```bash
8181-curl localhost:2470
8282-```
8383-8484-## PDS Crawling
8585-8686-see [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
8787-8888-for 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)
8989-9090-you 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)
9191-9292-make the script executable and run it and redirect the output to a text file
9393-9494-```bash
9595-chmod u+x pull-hosts.sh
9696-9797-./pull-hosts > hosts.txt
9898-```
9999-100100-we can then use `goat` to add hosts to the relay
101101-102102-```bash
103103-shuf hosts.txt | RELAY_HOST=http://localhost:2470 parallel goat relay admin host add {}
104104-```33+see [bluesky deploy recipes repo](https://github.com/nulfrost/deploy-recipes/blob/relay-recipe/atproto-relay-docker/README.md) for guide on how to deploy this setup