Mirror from bluesky-social/pds

First pass at the self-hosting README

Jake Gold 30d03d06

+195
+195
README.md
··· 1 + # PDS 2 + 3 + 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. 4 + 5 + ## FAQ 6 + 7 + ### What is Bluesky? 8 + 9 + Bluesky is a social media application built on AT Protocol. 10 + 11 + Please visit the [Bluesky website](https://bsky.app/) for more information. 12 + 13 + ### What is AT Protocol? 14 + 15 + The Authenticated Transfer Protocol, aka ATP, is a protocol for large-scale distributed social applications. 16 + 17 + Please visit the [AT Protocol docs](https://atproto.com/guides/overview) for additional information. 18 + 19 + ### Where is the code? 20 + 21 + * [Canonical TypeScript code](https://github.com/bluesky-social/atproto) 22 + * [Experimental Go code](https://github.com/bluesky-social/indigo) 23 + 24 + ## Self-hosting a PDS 25 + 26 + Self-hosting a Bluesky PDS means running your own Personal Data Server that is capable of federating with the wider Bluesky social network. 27 + 28 + ### Launch your server 29 + 30 + Launch a server on any cloud provider, for example [Digital Ocean](https://digitalocean.com/) and [Vultr](https://vultr.com/) are two popular choices. 31 + 32 + 33 + **Requirements** 34 + * Public internet access 35 + * Public IPv4 address 36 + * Public access on ports 80/tcp and 443/tcp 37 + 38 + **Recommendations** 39 + | | | 40 + | ---------------- | ---------------- | 41 + | Operating System | Ubuntu 22.04 LTS | 42 + | Memory (RAM) | 2+ GB | 43 + | CPU Cores | 2+ | 44 + | Storage | 40+ GB SSD | 45 + 46 + 47 + ### Install your server 48 + 49 + 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/). 50 + 51 + ### Open your firewall 52 + 53 + One of the most common sources of misconfiguration is not opening firewall ports correctly. Please be sure to double check this step. 54 + 55 + It may be helpful to use a remote [port scanning](https://dnschecker.org/port-scanner.php) service to verify that access is permitted. 56 + 57 + #### Open ports on your cloud and local firewalls 58 + 59 + In your cloud provider's console, the following ports should be open to access from the public internet. 60 + 61 + * 80/tcp (Used only for TLS certification verification) 62 + * 443/tcp (Used for all application requests) 63 + 64 + #### Open ports using ufw 65 + 66 + If your VM is running a Linux firewall managed with `ufw`, you will also need to open these same ports on your VM itself. 67 + 68 + ```bash 69 + $ sudo ufw allow 80/tcp 70 + $ sudo ufw allow 443/tcp 71 + ``` 72 + 73 + ### Install Docker 74 + 75 + 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/). 76 + 77 + **NOTE:** All of the following commands should be run on your server via ssh. 78 + 79 + #### Uninstall old versions 80 + 81 + ```bash 82 + sudo apt-get remove docker docker-engine docker.io containerd runc 83 + ``` 84 + 85 + #### Set up the repository 86 + 87 + ```bash 88 + sudo apt-get update 89 + sudo apt-get install \ 90 + ca-certificates \ 91 + curl \ 92 + gnupg 93 + ``` 94 + 95 + ```bash 96 + sudo install -m 0755 -d /etc/apt/keyrings 97 + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 98 + sudo chmod a+r /etc/apt/keyrings/docker.gpg 99 + ``` 100 + 101 + ```bash 102 + echo \ 103 + "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ 104 + "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ 105 + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 106 + ``` 107 + 108 + #### Install Docker Engine 109 + 110 + ```bash 111 + sudo apt-get update 112 + ``` 113 + 114 + ```bash 115 + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 116 + ``` 117 + 118 + #### Verify Docker Engine installation 119 + 120 + ```bash 121 + sudo docker run hello-world 122 + ``` 123 + 124 + ### Set up the PDS directory 125 + 126 + ```bash 127 + # Create the directory where all PDS data will be stored. 128 + sudo mkdir /data 129 + 130 + # Create the required caddy webserver directories. 131 + sudo mkdir --parents /data/caddy/{etc,data} 132 + ``` 133 + 134 + ### Start the PDS containers 135 + 136 + #### Download the Docker compose file 137 + 138 + Download the `sqlite-compose.yaml` to run your PDS with a local SQLite database. 139 + 140 + ```bash 141 + curl https://raw.githubusercontent.com/bluesky-social/pds/main/sqlite-compose.yaml >compose.yaml 142 + ``` 143 + 144 + Download the `postgres-compose.yaml` to run your PDS with a remote PostgreSQL database. 145 + 146 + ```bash 147 + curl https://raw.githubusercontent.com/bluesky-social/pds/main/postgres-compose.yaml >compose.yaml 148 + ``` 149 + 150 + #### Edit your compose.yaml file 151 + 152 + You will need to customize various settings configured through the PDS environment variables. 153 + 154 + | Environment Variable | Value | 155 + | --------------------- | --------------------------------------------- | 156 + | PDS_DOMAIN | example.com | 157 + | PDS_DATABASE_URL | postgresql://user:password@host:port/database | 158 + | PDS_ADMIN_EMAIL | you@example.com | 159 + | ... | ... | 160 + 161 + #### Run docker compose 162 + 163 + Run `docker compose up` to start the three required containers. 164 + 165 + ```bash 166 + docker compose up --wait --detach 167 + ``` 168 + 169 + You should see output similar to this: 170 + 171 + ``` 172 + [+] Running 3/3 173 + ✔ Container watchtower Healthy 1.1s 174 + ✔ Container pds Healthy 1.1s 175 + ✔ Container caddy Healthy 1.0s 176 + ``` 177 + 178 + ### Verify your PDS is online 179 + 180 + You can check if your server is online and healthy by requesting the healthcheck endpoint. 181 + 182 + ```bash 183 + curl https://example.com/xrpc/_health 184 + {"version":"v1.2.3"} 185 + ``` 186 + 187 + ### Connecting to your server 188 + 189 + You can use the Bluesky app to connect to your server to create an account. 190 + 191 + 1. Download the Bluesky app 192 + 1. Enter the URL of your PDS (e.g. `https://example.com/`) 193 + 1. Create an account 194 + 195 +