···4455## Table of Contents
6677-* [FAQ](#faq)
77+<!-- markdown-toc -i README.md -->
88+99+<!-- toc -->
1010+1111+- [FAQ](#faq)
812 * [What is Bluesky?](#what-is-bluesky)
913 * [What is AT Protocol?](#what-is-at-protocol)
1010- * [How can developers get invite codes?](#how-can-developers-get-invite-codes)
1114 * [Where is the code?](#where-is-the-code)
1215 * [What is the current status of federation?](#what-is-the-current-status-of-federation)
1316 * [What should I know about running a PDS in the developer sandbox?](#what-should-i-know-about-running-a-pds-in-the-developer-sandbox)
1414-* [Self\-hosting PDS](#self-hosting-pds)
1515- * [Preparation for self\-hosting PDS](#preparation-for-self-hosting-pds)
1717+- [Self-hosting PDS](#self-hosting-pds)
1818+ * [Preparation for self-hosting PDS](#preparation-for-self-hosting-pds)
1619 * [Open your cloud firewall for HTTP and HTTPS](#open-your-cloud-firewall-for-http-and-https)
1720 * [Configure DNS for your domain](#configure-dns-for-your-domain)
1821 * [Check that DNS is working as expected](#check-that-dns-is-working-as-expected)
1919- * [Automatic install on Ubuntu 20\.04/22\.04 or Debian 11/12](#automatic-install-on-ubuntu-20042204-or-debian-1112)
2020- * [Installing manually on Ubuntu 22\.04](#installing-manually-on-ubuntu-2204)
2121- * [Open ports on your Linux firewall](#open-ports-on-your-linux-firewall)
2222- * [Install Docker](#install-docker)
2323- * [Uninstall old versions](#uninstall-old-versions)
2424- * [Set up the repository](#set-up-the-repository)
2525- * [Install Docker Engine](#install-docker-engine)
2626- * [Verify Docker Engine installation](#verify-docker-engine-installation)
2727- * [Set up the PDS directory](#set-up-the-pds-directory)
2828- * [Create the Caddyfile](#create-the-caddyfile)
2929- * [Create the PDS env configuration file](#create-the-pds-env-configuration-file)
3030- * [Start the PDS containers](#start-the-pds-containers)
3131- * [Download the Docker compose file](#download-the-docker-compose-file)
3232- * [Create the systemd service](#create-the-systemd-service)
3333- * [Start the service](#start-the-service)
3434- * [Verify your PDS is online](#verify-your-pds-is-online)
3535- * [Obtain your PDS admin password](#obtain-your-pds-admin-password)
3636- * [Generate an invite code for your PDS](#generate-an-invite-code-for-your-pds)
3737- * [Connecting to your server](#connecting-to-your-server)
3838- * [Manually updating your PDS](#manually-updating-your-pds)
3939-* [PDS environment variables](#pds-environment-variables)
2222+ * [Installer on Ubuntu 20.04/22.04 and Debian 11/12](#installer-on-ubuntu-20042204-and-debian-1112)
2323+ * [Verifying that your PDS is online and accessible](#verifying-that-your-pds-is-online-and-accessible)
2424+ * [Creating an account using pdsadmin](#creating-an-account-using-pdsadmin)
2525+ * [Creating an account using an invite code](#creating-an-account-using-an-invite-code)
2626+ * [Using the Bluesky app with your PDS](#using-the-bluesky-app-with-your-pds)
2727+ * [Updating your PDS](#updating-your-pds)
40282929+<!-- tocstop -->
41304231## FAQ
4332···45344635Bluesky is a social media application built on AT Protocol.
47364848-Please visit the [Bluesky website](https://bsky.app/) for more information.
3737+Please visit the [Bluesky website](https://bsky.social/) for more information.
49385039### What is AT Protocol?
5140···53425443Please visit the [AT Protocol docs](https://atproto.com/guides/overview) for additional information.
55445656-### How can developers get invite codes?
5757-5858-There is no invite required to join the sandbox network. Simply set up your own PDS and generate your own invite codes to create accounts. If you desire an account on the production network (on the official Bluesky PDS) please check out the [Bluesky Developer Waitlist](https://docs.google.com/forms/d/e/1FAIpQLSfCuguykw3HaPxIZMJQKRu8_-vsRew90NALVTDOjCSPDmsGNg/viewform) which prioritizes access for developers wanting to build software on atproto.
5959-6045### Where is the code?
61466262-* [Canonical TypeScript code](https://github.com/bluesky-social/atproto)
6363-* [Experimental Go code](https://github.com/bluesky-social/indigo)
4747+* [TypeScript code](https://github.com/bluesky-social/atproto)
4848+* [Go code](https://github.com/bluesky-social/indigo)
64496550### What is the current status of federation?
66516767-We do not currently support PDS federation on the production network but it is now possible to federate in the developer sandbox.
5252+As of Feb, 2024, the AT Protocol data service (PDS) is now open to federation for self-hosters!
5353+5454+✅ Federated domain handles (e.g. `@nytimes.com`)
5555+5656+✅ Federated feed generators (custom algorithms)
5757+5858+✅ Federated relays (event firehose)
5959+6060+✅ Federated app views (API service)
6161+6262+✅ Federated data for self-hosters (PDS hosting)
6363+6464+🟩 Federated moderation (labeling) (coming soon)
6565+6666+🟩 Federated data for large service providers (coming soon)
68676968### What should I know about running a PDS in the developer sandbox?
6969+7070+Developers may now run self-hosted PDS hosts on the production network!
7171+7272+Though it is still recommended to run experiments in the developer sandbox network.
70737174Read the [SANDBOX.md](https://github.com/bluesky-social/pds/blob/main/SANDBOX.md) for an overview of the sandbox network.
7275···134137135138These should all return your server's public IP.
136139137137-### Automatic install on Ubuntu 20.04/22.04 or Debian 11/12
140140+### Installer on Ubuntu 20.04/22.04 and Debian 11/12
138141139139-On your server via ssh, run the installer script:
142142+On your server via ssh, download the installer script using wget:
140143141144```bash
142145wget https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh
143146```
144147145145-```bash
146146-sudo bash installer.sh
147147-```
148148-149149-### Installing manually on Ubuntu 22.04
150150-151151-#### Open ports on your Linux firewall
152152-153153-If your server is running a Linux firewall managed with `ufw`, you will need to open these ports:
154154-155155-```bash
156156-$ sudo ufw allow 80/tcp
157157-$ sudo ufw allow 443/tcp
158158-```
159159-160160-#### Install Docker
161161-162162-On your server, install Docker CE (Community Edition), using the the following instructions. For other operating systems you may reference the [official Docker install guides](https://docs.docker.com/engine/install/).
163163-164164-**Note:** All of the following commands should be run on your server via ssh.
165165-166166-##### Uninstall old versions
167167-168168-```bash
169169-sudo apt-get remove docker docker-engine docker.io containerd runc
170170-```
171171-172172-##### Set up the repository
173173-174174-```bash
175175-sudo apt-get update
176176-sudo apt-get install \
177177- ca-certificates \
178178- curl \
179179- gnupg
180180-```
181181-182182-```bash
183183-sudo install -m 0755 -d /etc/apt/keyrings
184184-curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
185185-sudo chmod a+r /etc/apt/keyrings/docker.gpg
186186-```
187187-188188-```bash
189189-echo \
190190- "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
191191- "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
192192- sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
193193-```
194194-195195-##### Install Docker Engine
196196-197197-```bash
198198-sudo apt-get update
199199-```
200200-201201-```bash
202202-sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
203203-```
204204-205205-##### Verify Docker Engine installation
206206-207207-```bash
208208-sudo docker run hello-world
209209-```
210210-211211-#### Set up the PDS directory
212212-213213-```bash
214214-sudo mkdir /pds
215215-sudo mkdir --parents /pds/caddy/data
216216-sudo mkdir --parents /pds/caddy/etc/caddy
217217-```
218218-219219-#### Create the Caddyfile
220220-221221-Be sure to replace `example.com` with your own domain.
222222-223223-```bash
224224-cat <<CADDYFILE | sudo tee /pds/caddy/etc/caddy/Caddyfile
225225-{
226226- email you@example.com
227227- on_demand_tls {
228228- ask http://localhost:3000
229229- }
230230-}
231231-232232-*.example.com, example.com {
233233- tls {
234234- on_demand
235235- }
236236- reverse_proxy http://localhost:3000
237237-}
238238-CADDYFILE
239239-```
240240-241241-#### Create the PDS env configuration file
242242-243243-You should fill in the first 5 values, but leave the rest untouched unless you have good reason to change it.
244244-245245-See the PDS environment variables section at the end of this README for explanations of each value
246246-247247-Your PDS will need two secp256k1 private keys provided as hex strings. You can securely generate these keys using `openssl` with the following command:
248248-249249-**Note:**
250250-* Replace `example.com` with your domain name.
251251-252252-```bash
253253-PDS_HOSTNAME="example.com"
254254-PDS_JWT_SECRET="$(openssl rand --hex 16)"
255255-PDS_ADMIN_PASSWORD="$(openssl rand --hex 16)"
256256-PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX="$(openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32)"
257257-PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX="$(openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32)"
258258-259259-cat <<PDS_CONFIG | sudo tee /pds/pds.env
260260-PDS_HOSTNAME=${PDS_HOSTNAME}
261261-PDS_JWT_SECRET=${PDS_JWT_SECRET}
262262-PDS_ADMIN_PASSWORD=${PDS_ADMIN_PASSWORD}
263263-PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX=${PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX}
264264-PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}
265265-PDS_DB_SQLITE_LOCATION=/pds/pds.sqlite
266266-PDS_BLOBSTORE_DISK_LOCATION=/pds/blocks
267267-PDS_DID_PLC_URL=https://plc.bsky-sandbox.dev
268268-PDS_BSKY_APP_VIEW_URL=https://api.bsky-sandbox.dev
269269-PDS_BSKY_APP_VIEW_DID=did:web:api.bsky-sandbox.dev
270270-PDS_CRAWLERS=https://bgs.bsky-sandbox.dev
271271-PDS_CONFIG
272272-```
273273-274274-#### Start the PDS containers
275275-276276-##### Download the Docker compose file
277277-278278-Download the `compose.yaml` to run your PDS, which includes the following containers:
279279-280280-* `pds` Node PDS server running on http://localhost:3000
281281-* `caddy` HTTP reverse proxy handling TLS and proxying requests to the PDS server
282282-* `watchtower` Daemon responsible for auto-updating containers to keep the server secure and federating
283283-284284-```bash
285285-curl https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml | sudo tee /pds/compose.yaml
286286-```
287287-288288-##### Create the systemd service
148148+or download it using curl:
289149290150```bash
291291-cat <<SYSTEMD_UNIT_FILE | sudo tee /etc/systemd/system/pds.service
292292-[Unit]
293293-Description=Bluesky PDS Service
294294-Documentation=https://github.com/bluesky-social/pds
295295-Requires=docker.service
296296-After=docker.service
297297-298298-[Service]
299299-Type=oneshot
300300-RemainAfterExit=yes
301301-WorkingDirectory=/pds
302302-ExecStart=/usr/bin/docker compose --file /pds/compose.yaml up --detach
303303-ExecStop=/usr/bin/docker compose --file /pds/compose.yaml down
304304-305305-[Install]
306306-WantedBy=default.target
307307-SYSTEMD_UNIT_FILE
151151+curl https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh >installer.sh
308152```
309153310310-##### Start the service
154154+And then run the installer using bash:
311155312312-**Reload the systemd daemon to create the new service:**
313156```bash
314314-sudo systemctl daemon-reload
157157+sudo bash installer.sh
315158```
316159317317-**Enable the systemd service:**
318318-```bash
319319-sudo systemctl enable pds
320320-```
160160+### Verifying that your PDS is online and accessible
321161322322-**Start the pds systemd service:**
323323-```bash
324324-sudo systemctl start pds
325325-```
162162+You can check if your server is online and healthy by requesting the healthcheck endpoint.
326163327327-**Ensure that containers are running**
164164+You can visit `https://example.com/xrpc/_health` in your browser. You should see a JSON response with a version.
328165329329-There should be a caddy, pds, and watchtower container running.
166166+For example:
330167331331-```bash
332332-sudo systemctl status pds
333168```
334334-335335-```bash
336336-sudo docker ps
337337-```
338338-339339-### Verify your PDS is online
340340-341341-You can check if your server is online and healthy by requesting the healthcheck endpoint.
342342-343343-```bash
344344-curl https://example.com/xrpc/_health
345169{"version":"0.2.2-beta.2"}
346170```
347171348348-### Obtain your PDS admin password
349349-350350-Your PDS admin password should be in your `pds.env` file if you used the installer script.
172172+### Creating an account using pdsadmin
351173352352-**For example:**
174174+Using ssh on your server, use `pdsadmin` to create an account if you haven't already.
353175354176```bash
355355-$ source /pds/pds.env
356356-$ echo $PDS_ADMIN_PASSWORD
357357-a7b5970b6a5077bb41fc68a26d30adda
177177+sudo pdsadmin account create
358178```
359359-### Generate an invite code for your PDS
360179361361-By default, your PDS will require an invite code to create an account.
180180+### Creating an account using an invite code
362181363363-You can generate a new invite code with the following command:
182182+Using ssh on your server, use `pdsadmin` to create an invite code.
364183365184```bash
366366-PDS_HOSTNAME="example.com"
367367-PDS_ADMIN_PASSWORD="<YOUR PDS ADMIN PASSWORD>"
368368-369369-curl --silent \
370370- --show-error \
371371- --request POST \
372372- --user "admin:${PDS_ADMIN_PASSWORD}" \
373373- --header "Content-Type: application/json" \
374374- --data '{"useCount": 1}' \
375375- https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode
185185+sudo pdsadmin create-invite-code
376186```
377187378378-**Note:** the `useCount` field specifies how many times an invite code can be used
188188+When creating an account using the app, enter this invite code.
379189380380-### Connecting to your server
190190+### Using the Bluesky app with your PDS
381191382382-You can use the Bluesky app to connect to your server to create an account.
192192+You can use the Bluesky app to connect to your PDS.
3831933841941. Get the Bluesky app
385385- * [Bluesky for Web (sandbox)](https://app.bsky-sandbox.dev/)
195195+ * [Bluesky for Web](https://bsky.app/)
386196 * [Bluesky for iPhone](https://apps.apple.com/us/app/bluesky-social/id6444370199)
387197 * [Bluesky for Android](https://play.google.com/store/apps/details?id=xyz.blueskyweb.app)
3881981. Enter the URL of your PDS (e.g. `https://example.com/`)
389389-1. Create an account using the generated invite code
390390-1. Create a post
391199392392-_Note: because we use on-the-fly TLS certs, it may take 10-30s for your handle to be accessible. If you aren't seeing your first post/profile, wait 30s and try to make another post._
200200+_Note: because the subdomain TLS certificate is created on-demand, it may take 10-30s for your handle to be accessible. If you aren't seeing your first post/profile, wait 30s and try to make another post._
393201394394-Checkout [SANDBOX.md](./SANDBOX.md) for an overview of participating in the sandbox network.
202202+### Updating your PDS
395203396396-### Manually updating your PDS
204204+It is recommended that you keep your PDS up to date with new versions, otherwise things may break. You can use the `pdsadmin` tool to update your PDS.
397205398398-If you use use Docker `compose.yaml` file in this repo, your PDS will automatically update nightly. To manually update to the latest version use the following commands.
399399-400400-**Pull the latest PDS container image:**
401206```bash
402402-sudo docker pull ghcr.io/bluesky-social/pds:latest
403403-```
404404-405405-**Restart PDS with the new container image:**
406406-```bash
407407-sudo systemctl restart pds
207207+sudo pdsadmin update
408208```
409409-410410-## PDS environment variables
411411-412412-You will need to customize various settings configured through the PDS environment variables. See the below table to find the variables you'll need to set.
413413-414414-| Environment Variable | Value | Should update? | Notes |
415415-| ----------------------------------------- | ---------------------------- | -------------- | --------------------------------------------------------------------------- |
416416-| PDS_HOSTNAME | example.com | ✅ | Public domain you intend to deploy your service at |
417417-| PDS_JWT_SECRET | jwt-secret | ✅ | Use a secure high-entropy string that is 32 characters in length |
418418-| PDS_ADMIN_PASSWORD | admin-pass | ✅ | Use a secure high-entropy string that is 32 characters in length |
419419-| PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX | 3ee68... | ✅ | See above Generate Keys section - once set, do not change |
420420-| PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX | e049f... | ✅ | See above Generate Keys section - once set, do not change |
421421-| PDS_DB_SQLITE_LOCATION | /pds/pds.sqlite | ❌ | Or use `PDS_DB_POSTGRES_URL` depending on which database you intend to use |
422422-| PDS_BLOBSTORE_DISK_LOCATION | /pds/blocks | ❌ | Only update if you update the mounted volume for your docker image as well |
423423-| PDS_DID_PLC_URL | https://plc.bsky-sandbox.dev | ❌ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
424424-| PDS_BSKY_APP_VIEW_URL | https://api.bsky-sandbox.dev | ❌ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
425425-| PDS_BSKY_APP_VIEW_DID | did:web:api.bsky-sandbox.dev | ❌ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
426426-| PDS_CRAWLERS | https://bgs.bsky-sandbox.dev | ❌ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
427427-428428-There are additional environment variables that can be tweaked depending on how you're running your service. For instance, storing blobs in AWS S3, keys in AWS KMS, or setting up an email service.
429429-430430-Feel free to explore those [Here](https://github.com/bluesky-social/atproto/blob/main/packages/pds/src/config/env.ts). However, we will not be providing support for more advanced configurations.
+26
SANDBOX.md
···10101111Given that this is a testing environment, we will be defederating from any instances that do not abide by these guidelines, or that cause unnecessary trouble, and will not be providing specific justifications for these decisions.
12121313+<!-- markdown-toc -i SANDBOX.md -->
1414+1515+<!-- toc -->
1616+1717+- [Guidelines that must be followed](#guidelines-that-must-be-followed)
1818+ * [Post responsibly](#post-responsibly)
1919+ * [Keep the emphasis on testing](#keep-the-emphasis-on-testing)
2020+ * [Do limit account creation](#do-limit-account-creation)
2121+ * [Don’t expect persistence or uptime](#dont-expect-persistence-or-uptime)
2222+ * [Don't advertise your service as being "Bluesky"](#dont-advertise-your-service-as-being-bluesky)
2323+ * [Do not mirror sandbox did:plcs to production](#do-not-mirror-sandbox-didplcs-to-production)
2424+ * [Status and Wipes](#status-and-wipes)
2525+ + [🐉 Beware of dragons!](#%F0%9F%90%89-beware-of-dragons)
2626+ + [Routine wipes](#routine-wipes)
2727+- [Getting started](#getting-started)
2828+ * [Auto-updates](#auto-updates)
2929+ * [Odds & Ends & Warnings & Reminders](#odds--ends--warnings--reminders)
3030+- [Learn more about atproto federation](#learn-more-about-atproto-federation)
3131+ * [Network Services](#network-services)
3232+ + [PLC](#plc)
3333+ + [BGS](#bgs)
3434+ + [Bluesky App View](#bluesky-app-view)
3535+- [The PDS](#the-pds)
3636+3737+<!-- tocstop -->
3838+1339# Guidelines that must be followed
14401541Using the sandbox environment means you agree to adhere to our Guidelines. Please read the following carefully: