mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-02-08 21:30:08 +00:00
Nice things that make the repo a little more legit
This commit is contained in:
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM rust:1.91.1-alpine AS builder
|
||||
|
||||
RUN apk add ca-certificates openssl openssl-dev pkgconfig
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src
|
||||
|
||||
COPY src ./src
|
||||
COPY tests ./tests
|
||||
COPY migrations ./migrations
|
||||
COPY .sqlx ./.sqlx
|
||||
RUN touch src/main.rs && cargo build --release
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
COPY --from=builder /app/target/release/bspds /usr/local/bin/bspds
|
||||
COPY --from=builder /app/migrations /app/migrations
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV SERVER_HOST=0.0.0.0
|
||||
ENV SERVER_PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["bspds"]
|
||||
75
README.md
Normal file
75
README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Lewis' BS PDS Sandbox
|
||||
|
||||
When I'm actually done then yeah let's make this into a proper official-looking repo perhaps under an official-looking account or something.
|
||||
|
||||
This project implements a Personal Data Server (PDS) implementation for the AT Protocol.
|
||||
|
||||
Uses PostgreSQL instead of SQLite, S3-compatible blob storage, and aims to be a complete drop-in replacement for Bluesky's reference PDS implementation.
|
||||
|
||||
In fact I aim to also implement a plugin system soon, so that we can add things onto our own PDSes on top of the default BS.
|
||||
|
||||
I'm also taking ideas on what other PDSes lack, such as an on-PDS webpage that users can access to manage their records and preferences.
|
||||
|
||||
:3
|
||||
|
||||
# Running locally
|
||||
|
||||
The reader will need rust installed locally.
|
||||
|
||||
I personally run the postgres db, and an S3-compatible object store with podman compose up db objsto -d.
|
||||
|
||||
Run the PDS directly:
|
||||
|
||||
just run
|
||||
|
||||
Configuration is via environment variables:
|
||||
|
||||
DATABASE_URL postgres connection string
|
||||
S3_BUCKET blob storage bucket name
|
||||
S3_ENDPOINT S3 endpoint URL (for MinIO etc)
|
||||
AWS_ACCESS_KEY_ID S3 credentials
|
||||
AWS_SECRET_ACCESS_KEY
|
||||
AWS_REGION
|
||||
PDS_HOSTNAME public hostname of this PDS
|
||||
APPVIEW_URL appview to proxy unimplemented endpoints to
|
||||
RELAYS comma-separated list of relay WebSocket URLs
|
||||
|
||||
Optional email stuff:
|
||||
|
||||
MAIL_FROM_ADDRESS sender address (enables email notifications)
|
||||
MAIL_FROM_NAME sender name (default: BSPDS)
|
||||
SENDMAIL_PATH path to sendmail binary
|
||||
|
||||
Development
|
||||
|
||||
just shows available commands
|
||||
just test run tests (spins up postgres and minio via testcontainers)
|
||||
just lint clippy + fmt check
|
||||
just db-reset drop and recreate local database
|
||||
|
||||
The test suite uses testcontainers so you don't need to set up anything manually for running tests.
|
||||
|
||||
## What's implemented
|
||||
|
||||
Most of the com.atproto.* namespace is done. Server endpoints, repo operations, sync, identity, admin, moderation. The firehose websocket works. OAuth is not done yet.
|
||||
|
||||
See TODO.md for the full breakdown of what's done and what's left.
|
||||
|
||||
Structure
|
||||
|
||||
src/
|
||||
main.rs server entrypoint
|
||||
lib.rs router setup
|
||||
state.rs app state (db pool, stores)
|
||||
api/ XRPC handlers organized by namespace
|
||||
auth/ JWT handling
|
||||
repo/ postgres block store
|
||||
storage/ S3 blob storage
|
||||
sync/ firehose, relay clients
|
||||
notifications/ email service
|
||||
tests/ integration tests
|
||||
migrations/ sqlx migrations
|
||||
|
||||
License
|
||||
|
||||
idk
|
||||
@@ -6,16 +6,11 @@ services:
|
||||
image: bspds
|
||||
ports:
|
||||
- "3000:3000"
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
SERVER_HOST: 0.0.0.0
|
||||
SERVER_PORT: 3000
|
||||
DATABASE_URL: postgres://postgres:postgres@db:5432/pds
|
||||
S3_ENDPOINT: http://objsto:9000
|
||||
AWS_REGION: us-east-1
|
||||
S3_BUCKET: pds-blobs
|
||||
AWS_ACCESS_KEY_ID: minioadmin
|
||||
AWS_SECRET_ACCESS_KEY: minioadmin
|
||||
PDS_HOSTNAME: localhost:3000
|
||||
depends_on:
|
||||
- db
|
||||
- objsto
|
||||
|
||||
63
justfile
63
justfile
@@ -1,8 +1,38 @@
|
||||
# Run all tests
|
||||
default:
|
||||
@just --list
|
||||
|
||||
run:
|
||||
cargo run
|
||||
|
||||
run-release:
|
||||
cargo run --release
|
||||
|
||||
build:
|
||||
cargo build
|
||||
|
||||
build-release:
|
||||
cargo build --release
|
||||
|
||||
check:
|
||||
cargo check
|
||||
|
||||
clippy:
|
||||
cargo clippy -- -D warnings
|
||||
|
||||
fmt:
|
||||
cargo fmt
|
||||
|
||||
fmt-check:
|
||||
cargo fmt -- --check
|
||||
|
||||
lint: fmt-check clippy
|
||||
|
||||
test:
|
||||
cargo test
|
||||
|
||||
# Run specific test suites if needed
|
||||
test-verbose:
|
||||
cargo test -- --nocapture
|
||||
|
||||
test-repo:
|
||||
cargo test --test repo
|
||||
|
||||
@@ -23,3 +53,32 @@ test-identity:
|
||||
|
||||
test-auth:
|
||||
cargo test --test auth
|
||||
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
doc:
|
||||
cargo doc --open
|
||||
|
||||
db-create:
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/pds" sqlx database create
|
||||
|
||||
db-migrate:
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/pds" sqlx migrate run
|
||||
|
||||
db-reset:
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/pds" sqlx database drop -y
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/pds" sqlx database create
|
||||
DATABASE_URL="postgres://postgres:postgres@localhost:5432/pds" sqlx migrate run
|
||||
|
||||
docker-up:
|
||||
docker compose up -d
|
||||
|
||||
docker-down:
|
||||
docker compose down
|
||||
|
||||
docker-logs:
|
||||
docker compose logs -f
|
||||
|
||||
docker-build:
|
||||
docker compose build
|
||||
|
||||
Reference in New Issue
Block a user