2024-12-03 01:35:55 +00:00
# bluesky-pds-docker
2024-12-10 17:29:27 +00:00
A self-contained Docker image for the [Bluesky PDS (Personal Data Server) ](https://github.com/bluesky-social/pds ) for use with Traefik. This image is pinned to v0.4.74.
2024-12-03 01:43:49 +00:00
2024-12-10 20:08:45 +00:00
It is required to run the instance behind a proxy (like traefik) to generate SSL certificates. This will not work otherwise. The standard pds install includes caddy to handle this. A wildcard DNS assignment along with a wildcard SSL certificate is required. I use Cloudflare for this, see the screenshot below.
2024-12-03 22:48:12 +00:00
2024-12-10 20:08:45 +00:00
This is not intended for production, and I am not responsible for any data loss or security issues. This is a personal project, and I am not affiliated with Bluesky.
2024-12-02 00:15:39 +00:00
## Deployment
2024-12-10 20:08:45 +00:00
Before changing images or upgrading, backup the files made in the volume.
### Reqirements
I haven't verified these are the minimum requirements, but they are what I found to be necessary after starting this readme. I probably had some dependencies installed already.
2024-12-10 17:29:27 +00:00
#### Manjaro/Arch
2024-12-02 00:15:39 +00:00
```bash
2024-12-10 20:08:45 +00:00
sudo pacman -S jq
2024-12-10 17:29:27 +00:00
```
2024-12-02 00:15:39 +00:00
2024-12-10 20:08:45 +00:00
#### Debian/Ubunutu
2024-12-03 22:48:12 +00:00
2024-12-10 17:29:27 +00:00
```bash
sudo apt install make xxd
2024-12-02 00:15:39 +00:00
```
2024-12-03 23:39:25 +00:00
2024-12-10 17:29:27 +00:00
### Setup
2024-12-03 23:39:25 +00:00
2024-12-10 17:29:27 +00:00
Generate secrets and add them to `.env` file. See [example.env ](example.env ) as an example.
2024-12-03 22:48:12 +00:00
2024-12-10 17:29:27 +00:00
```bash
# Generate secret environment variables
echo PDS_ADMIN_PASSWORD: $(openssl rand --hex 16)
2024-12-10 20:08:45 +00:00
2024-12-10 17:29:27 +00:00
echo PDS_JWT_SECRET: $(openssl rand --hex 16)
2024-12-10 20:08:45 +00:00
2024-12-10 17:29:27 +00:00
echo 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)
```
2024-12-02 00:15:39 +00:00
2024-12-10 20:08:45 +00:00
### Docker Compose Setup
Full list of additional Environment Variables provided by bluesky upstream can be found in the [packages/pds/src/config/env.ts ](https://github.com/bluesky-social/atproto/blob/main/packages/pds/src/config/env.ts )
By default, the image uses 1000:1000 as the UID:GID for the user. This can be changed by setting the `PUID` and `PGID` environment variables.
2024-12-02 00:15:39 +00:00
2024-12-10 20:08:45 +00:00
The compose element `hostname` must be the same value as `PDS_HOSTNAME` .
#### Traefik
2024-12-03 23:39:25 +00:00
2024-12-02 00:15:39 +00:00
```yaml
2024-12-10 20:08:45 +00:00
# Traefik Proxy
2024-12-02 00:15:39 +00:00
services:
bluesky-pds:
2024-12-03 01:35:55 +00:00
container_name: bluesky-pds
2024-12-10 20:08:45 +00:00
image: gravityfargo/bluesky-pds:0.4.74
2024-12-29 03:26:14 +00:00
hostname: example.com
extra_hosts:
- "example.com:0.0.0.0" # domain:external_ip
2024-12-10 20:08:45 +00:00
networks:
- proxy
2024-12-03 22:48:12 +00:00
environment:
2024-12-10 17:29:27 +00:00
# Define variables here or in a .env file
2024-12-03 22:48:12 +00:00
PDS_JWT_SECRET: ...
PDS_ADMIN_PASSWORD: ...
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX: ...
2024-12-10 20:08:45 +00:00
PDS_HOSTNAME: example.com
2024-12-10 22:56:45 +00:00
PDS_EMAIL_SMTP_URL: smtps://resend:< your api key here > @smtp.resend.com:465/
PDS_EMAIL_FROM_ADDRESS: admin@your.domain
2024-12-10 20:08:45 +00:00
PUID: 1005
PGID: 1005
2024-12-02 00:15:39 +00:00
volumes:
2024-12-03 23:39:25 +00:00
- ./bluesky-pds:/pds
2024-12-10 20:08:45 +00:00
labels:
traefik.enable: "true"
traefik.http.routers.bluesky-pds-insecure.entrypoints: http
traefik.http.routers.bluesky-pds-insecure.rule: HostRegexp(`^.+\.${URL_NAME}\.${URL_SUFFIX}$`) || Host(`${PDS_HOSTNAME}`)
# traefik.http.routers.bluesky-pds-insecure.middlewares: BlueskyHeaders@file
traefik.http.routers.bluesky-pds-secure.entrypoints: https
traefik.http.routers.bluesky-pds-secure.rule: HostRegexp(`^.+\.${URL_NAME}\.${URL_SUFFIX}$`) || Host(`${PDS_HOSTNAME}`)
traefik.http.routers.bluesky-pds-secure.tls: "true"
traefik.http.services.bluesky-pds.loadbalancer.server.scheme: http
traefik.http.services.bluesky-pds.loadbalancer.server.port: 3000
# traefik.http.routers.bluesky-pds-secure.middlewares: BlueskyHeaders@file
2024-12-02 00:15:39 +00:00
```
2024-12-03 01:43:49 +00:00
2024-12-10 20:08:45 +00:00
#### Standalone
I do not run this, but it should be possible.
2024-12-03 01:43:49 +00:00
2024-12-03 22:48:12 +00:00
```yaml
2024-12-10 20:08:45 +00:00
# Standalone, you'll need to add a proxy in front of this with SSL.
2024-12-03 22:48:12 +00:00
services:
bluesky-pds:
container_name: bluesky-pds
2024-12-10 20:08:45 +00:00
hostname: example.com
2024-12-29 03:26:14 +00:00
extra_hosts:
- "example.com:0.0.0.0" # domain:external_ip
2024-12-10 20:08:45 +00:00
image: gravityfargo/bluesky-pds:0.4.74
environment:
# Define variables here or in a .env file
PDS_JWT_SECRET: ...
PDS_ADMIN_PASSWORD: ...
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX: ...
PDS_HOSTNAME: example.com
PDS_EMAIL_SMTP_URL: ""
PDS_EMAIL_FROM_ADDRESS: ""
PUID: 1005
PGID: 1005
2024-12-03 22:48:12 +00:00
volumes:
2024-12-03 23:39:25 +00:00
- ./bluesky-pds:/pds
2024-12-03 22:48:12 +00:00
```
2024-12-03 23:39:25 +00:00
2024-12-03 22:48:12 +00:00
#### Middleware
2024-12-03 23:39:25 +00:00
2024-12-10 20:08:45 +00:00
I think file configs are cleaner than having a billion labels. This is not required, but it's nice to have.
2024-12-03 23:39:25 +00:00
2024-12-03 22:48:12 +00:00
```yaml
2024-12-10 17:29:27 +00:00
# middleware.yaml
2024-12-03 22:48:12 +00:00
http:
middlewares:
BlueskyHeaders:
headers:
accessControlAllowMethods:
- GET
- OPTIONS
- PUT
- POST
- DELETE
accessControlAllowHeaders: "*"
accessControlAllowOriginList: "*"
addVaryHeader: true
stsSeconds: 63072000
```
2024-12-03 23:39:25 +00:00
2024-12-10 17:29:27 +00:00
#### Optional Proxy Network
2024-12-03 01:43:49 +00:00
2024-12-03 22:48:12 +00:00
```bash
2024-12-10 17:29:27 +00:00
docker network create --subnet=192.168.1.0/24 --ipv6 --attachable proxy
# /etc/docker/daemon.json
# {
# "ipv6": true,
# "fixed-cidr-v6": "2001:db8:1::/64"
# }
2024-12-03 22:48:12 +00:00
```
2024-12-10 17:29:27 +00:00
#### Cloudflare DNS
![alt text ](assets/image.png )
2024-12-10 20:08:45 +00:00
2024-12-29 03:26:14 +00:00
#### Running Commands
```bash
docker exec -it bluesky-pds bash
pdsadmin account create
pdsadmin create-invite-code
```
2024-12-10 22:56:45 +00:00
#### Protonmail SMTP
`PDS_EMAIL_SMTP_URL: smtp://user@example.com:TOKEN@smtp.protonmail.ch:587/`
`PDS_EMAIL_FROM_ADDRESS: user@example.com`
2024-12-10 20:08:45 +00:00
## Development
The development enviornment must be behind a proxy to generate SSL certificates. This will not work otherwise. In my case, I use Traefik installed on a VPS that's dedicated to development.
I suggest buying a domain name for testing. I have one I use that's for a seperate project, but getting a throwaway domain is also an option. Millage may vary.
```bash
make generate-env
```
Then set the variables
- `PDS_HOSTNAME=example.com`
- `URL_NAME=example`
- `URL_SUFFIX=com`
Build the base image. This will take a while.
```bash
make build-base
```
Make edits as needed. Then build the dev image for testing.
```bash
make build-tag TAG=dev
```
Run the dev image.
```bash
make run
# or
docker-compose up
```