···11+# PDS
22+33+Welcome to the repository for the official Bluesky PDS (Personal Data Server). This repository includes container images and documentation designed to assist technical people with self-hosting a Bluesky PDS.
44+55+## FAQ
66+77+### What is Bluesky?
88+99+Bluesky is a social media application built on AT Protocol.
1010+1111+Please visit the [Bluesky website](https://bsky.app/) for more information.
1212+1313+### What is AT Protocol?
1414+1515+The Authenticated Transfer Protocol, aka ATP, is a protocol for large-scale distributed social applications.
1616+1717+Please visit the [AT Protocol docs](https://atproto.com/guides/overview) for additional information.
1818+1919+### Where is the code?
2020+2121+* [Canonical TypeScript code](https://github.com/bluesky-social/atproto)
2222+* [Experimental Go code](https://github.com/bluesky-social/indigo)
2323+2424+## Self-hosting a PDS
2525+2626+Self-hosting a Bluesky PDS means running your own Personal Data Server that is capable of federating with the wider Bluesky social network.
2727+2828+### Launch your server
2929+3030+Launch a server on any cloud provider, for example [Digital Ocean](https://digitalocean.com/) and [Vultr](https://vultr.com/) are two popular choices.
3131+3232+3333+**Requirements**
3434+* Public internet access
3535+* Public IPv4 address
3636+* Public access on ports 80/tcp and 443/tcp
3737+3838+**Recommendations**
3939+| | |
4040+| ---------------- | ---------------- |
4141+| Operating System | Ubuntu 22.04 LTS |
4242+| Memory (RAM) | 2+ GB |
4343+| CPU Cores | 2+ |
4444+| Storage | 40+ GB SSD |
4545+4646+4747+### Install your server
4848+4949+Install your Ubuntu 22.04 server, and then ensure that you can ssh to it. It is recommended that you only allow port 22 (ssh) traffic from your own public IP address. You can check your current public IP address using [ifconfig.me](https://ifconfig.me/).
5050+5151+### Open your firewall
5252+5353+One of the most common sources of misconfiguration is not opening firewall ports correctly. Please be sure to double check this step.
5454+5555+It may be helpful to use a remote [port scanning](https://dnschecker.org/port-scanner.php) service to verify that access is permitted.
5656+5757+#### Open ports on your cloud and local firewalls
5858+5959+In your cloud provider's console, the following ports should be open to access from the public internet.
6060+6161+* 80/tcp (Used only for TLS certification verification)
6262+* 443/tcp (Used for all application requests)
6363+6464+#### Open ports using ufw
6565+6666+If your VM is running a Linux firewall managed with `ufw`, you will also need to open these same ports on your VM itself.
6767+6868+```bash
6969+$ sudo ufw allow 80/tcp
7070+$ sudo ufw allow 443/tcp
7171+```
7272+7373+### Install Docker
7474+7575+To install Docker CE (Community Edition) on Ubuntu 22.04, use the the following instructions. For other operating systems you may reference the [official Docker install guides](https://docs.docker.com/engine/install/).
7676+7777+**NOTE:** All of the following commands should be run on your server via ssh.
7878+7979+#### Uninstall old versions
8080+8181+```bash
8282+sudo apt-get remove docker docker-engine docker.io containerd runc
8383+```
8484+8585+#### Set up the repository
8686+8787+```bash
8888+sudo apt-get update
8989+sudo apt-get install \
9090+ ca-certificates \
9191+ curl \
9292+ gnupg
9393+```
9494+9595+```bash
9696+sudo install -m 0755 -d /etc/apt/keyrings
9797+curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
9898+sudo chmod a+r /etc/apt/keyrings/docker.gpg
9999+```
100100+101101+```bash
102102+echo \
103103+ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
104104+ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
105105+ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
106106+```
107107+108108+#### Install Docker Engine
109109+110110+```bash
111111+sudo apt-get update
112112+```
113113+114114+```bash
115115+sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
116116+```
117117+118118+#### Verify Docker Engine installation
119119+120120+```bash
121121+sudo docker run hello-world
122122+```
123123+124124+### Set up the PDS directory
125125+126126+```bash
127127+# Create the directory where all PDS data will be stored.
128128+sudo mkdir /data
129129+130130+# Create the required caddy webserver directories.
131131+sudo mkdir --parents /data/caddy/{etc,data}
132132+```
133133+134134+### Start the PDS containers
135135+136136+#### Download the Docker compose file
137137+138138+Download the `sqlite-compose.yaml` to run your PDS with a local SQLite database.
139139+140140+```bash
141141+curl https://raw.githubusercontent.com/bluesky-social/pds/main/sqlite-compose.yaml >compose.yaml
142142+```
143143+144144+Download the `postgres-compose.yaml` to run your PDS with a remote PostgreSQL database.
145145+146146+```bash
147147+curl https://raw.githubusercontent.com/bluesky-social/pds/main/postgres-compose.yaml >compose.yaml
148148+```
149149+150150+#### Edit your compose.yaml file
151151+152152+You will need to customize various settings configured through the PDS environment variables.
153153+154154+| Environment Variable | Value |
155155+| --------------------- | --------------------------------------------- |
156156+| PDS_DOMAIN | example.com |
157157+| PDS_DATABASE_URL | postgresql://user:password@host:port/database |
158158+| PDS_ADMIN_EMAIL | you@example.com |
159159+| ... | ... |
160160+161161+#### Run docker compose
162162+163163+Run `docker compose up` to start the three required containers.
164164+165165+```bash
166166+docker compose up --wait --detach
167167+```
168168+169169+You should see output similar to this:
170170+171171+```
172172+[+] Running 3/3
173173+ ✔ Container watchtower Healthy 1.1s
174174+ ✔ Container pds Healthy 1.1s
175175+ ✔ Container caddy Healthy 1.0s
176176+```
177177+178178+### Verify your PDS is online
179179+180180+You can check if your server is online and healthy by requesting the healthcheck endpoint.
181181+182182+```bash
183183+curl https://example.com/xrpc/_health
184184+{"version":"v1.2.3"}
185185+```
186186+187187+### Connecting to your server
188188+189189+You can use the Bluesky app to connect to your server to create an account.
190190+191191+1. Download the Bluesky app
192192+1. Enter the URL of your PDS (e.g. `https://example.com/`)
193193+1. Create an account
194194+195195+