chore: update README, Dockerfile, compose.yml — add frontend/worker services, SSR env var, feature list
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Has been cancelled
test / unit (pull_request) Has been cancelled
test / integration (pull_request) Has been cancelled
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Has been cancelled
test / unit (pull_request) Has been cancelled
test / integration (pull_request) Has been cancelled
This commit is contained in:
37
README.md
37
README.md
@@ -6,8 +6,11 @@ A self-hosted microblogging server with full ActivityPub federation. Write short
|
|||||||
|
|
||||||
- Short-form posts (thoughts) with replies, boosts, and likes
|
- Short-form posts (thoughts) with replies, boosts, and likes
|
||||||
- Full ActivityPub federation — follow/unfollow remote actors, accept/reject followers, federated content broadcast as `Note` objects, paginated outbox, NodeInfo discovery, WebFinger, shared inbox, actor profile sync
|
- Full ActivityPub federation — follow/unfollow remote actors, accept/reject followers, federated content broadcast as `Note` objects, paginated outbox, NodeInfo discovery, WebFinger, shared inbox, actor profile sync
|
||||||
|
- **Remote actor discovery** — search by `@user@instance` handle, view full remote profiles (bio, banner, profile fields, posts, followers, following tabs), follow from within the UI
|
||||||
|
- **Worker-backed remote caches** — remote posts and follower/following lists are fetched by the NATS worker and cached locally; profiles populate on first visit and refresh in the background
|
||||||
|
- Content negotiation at `GET /users/{username}` — serves ActivityPub actor JSON or REST profile based on `Accept` header
|
||||||
- Federation moderation — per-instance domain blocking, per-user actor blocking with `Block` activity delivery, delivery filter excludes blocked actors and blocked-domain inboxes
|
- Federation moderation — per-instance domain blocking, per-user actor blocking with `Block` activity delivery, delivery filter excludes blocked actors and blocked-domain inboxes
|
||||||
- Async event fan-out via NATS — notifications and AP delivery run in a separate worker process
|
- Async event fan-out via NATS JetStream — notifications and AP delivery run in a separate worker process; pull consumer with 1-hour TTL caching
|
||||||
- JWT authentication (Bearer token)
|
- JWT authentication (Bearer token)
|
||||||
- OpenAPI documentation at `/docs` (Swagger UI) and `/scalar` (Scalar)
|
- OpenAPI documentation at `/docs` (Swagger UI) and `/scalar` (Scalar)
|
||||||
- Full-text search over thoughts and users via PostgreSQL trigram indexes
|
- Full-text search over thoughts and users via PostgreSQL trigram indexes
|
||||||
@@ -87,18 +90,33 @@ All REST endpoints are under the root path. Authentication uses `Authorization:
|
|||||||
|
|
||||||
Interactive API documentation is available at runtime:
|
Interactive API documentation is available at runtime:
|
||||||
|
|
||||||
- **Swagger UI** — `http://localhost:3000/docs`
|
- **Swagger UI** — `http://localhost:8000/docs`
|
||||||
- **Scalar** — `http://localhost:3000/scalar`
|
- **Scalar** — `http://localhost:8000/scalar`
|
||||||
|
|
||||||
|
## Frontend
|
||||||
|
|
||||||
|
The Next.js frontend lives in `thoughts-frontend/`. It requires two environment variables:
|
||||||
|
|
||||||
|
```env
|
||||||
|
NEXT_PUBLIC_API_URL=http://localhost:8000 # client-side requests
|
||||||
|
NEXT_PUBLIC_SERVER_SIDE_API_URL=http://localhost:8000 # SSR requests
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd thoughts-frontend
|
||||||
|
bun install
|
||||||
|
bun run dev # http://localhost:3000
|
||||||
|
```
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
The image contains both `thoughts` (API server) and `thoughts-worker` (event processor). Run them as separate containers:
|
The backend image contains both `thoughts` (API server) and `thoughts-worker` (event processor). Run them as separate containers:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t thoughts .
|
docker build -t thoughts .
|
||||||
|
|
||||||
# API server
|
# API server
|
||||||
docker run -p 3000:3000 \
|
docker run -p 8000:8000 \
|
||||||
-e DATABASE_URL=postgres://postgres:password@db:5432/thoughts \
|
-e DATABASE_URL=postgres://postgres:password@db:5432/thoughts \
|
||||||
-e JWT_SECRET=change-me \
|
-e JWT_SECRET=change-me \
|
||||||
-e BASE_URL=https://yourdomain.example.com \
|
-e BASE_URL=https://yourdomain.example.com \
|
||||||
@@ -112,8 +130,17 @@ docker run \
|
|||||||
-e NATS_URL=nats://nats:4222 \
|
-e NATS_URL=nats://nats:4222 \
|
||||||
--entrypoint ./thoughts-worker \
|
--entrypoint ./thoughts-worker \
|
||||||
thoughts
|
thoughts
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
docker build -t thoughts-frontend \
|
||||||
|
--build-arg NEXT_PUBLIC_API_URL=https://api.yourdomain.example.com \
|
||||||
|
--build-arg NEXT_PUBLIC_SERVER_SIDE_API_URL=http://thoughts:8000 \
|
||||||
|
thoughts-frontend/
|
||||||
|
docker run -p 3000:3000 thoughts-frontend
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See `compose.yml` for a full local development stack.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT License. See [LICENSE](LICENSE).
|
MIT License. See [LICENSE](LICENSE).
|
||||||
|
|||||||
41
compose.yml
41
compose.yml
@@ -22,5 +22,46 @@ services:
|
|||||||
- "8222:8222" # monitoring endpoint
|
- "8222:8222" # monitoring endpoint
|
||||||
command: ["--jetstream", "--http_port", "8222"]
|
command: ["--jetstream", "--http_port", "8222"]
|
||||||
|
|
||||||
|
api:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/thoughts
|
||||||
|
JWT_SECRET: change-me-in-production
|
||||||
|
BASE_URL: http://localhost:8000
|
||||||
|
NATS_URL: nats://nats:4222
|
||||||
|
RUST_LOG: info
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
nats:
|
||||||
|
condition: service_started
|
||||||
|
|
||||||
|
worker:
|
||||||
|
build: .
|
||||||
|
entrypoint: ["./thoughts-worker"]
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/thoughts
|
||||||
|
BASE_URL: http://localhost:8000
|
||||||
|
NATS_URL: nats://nats:4222
|
||||||
|
RUST_LOG: info
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
nats:
|
||||||
|
condition: service_started
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./thoughts-frontend
|
||||||
|
args:
|
||||||
|
NEXT_PUBLIC_API_URL: http://localhost:8000
|
||||||
|
NEXT_PUBLIC_SERVER_SIDE_API_URL: http://api:8000
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
depends_on:
|
||||||
|
- api
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ WORKDIR /app
|
|||||||
ARG NEXT_PUBLIC_API_URL
|
ARG NEXT_PUBLIC_API_URL
|
||||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||||
|
|
||||||
|
ARG NEXT_PUBLIC_SERVER_SIDE_API_URL
|
||||||
|
ENV NEXT_PUBLIC_SERVER_SIDE_API_URL=$NEXT_PUBLIC_SERVER_SIDE_API_URL
|
||||||
|
|
||||||
# Install dependencies with Bun for speed
|
# Install dependencies with Bun for speed
|
||||||
COPY --chown=node:node package.json bun.lock ./
|
COPY --chown=node:node package.json bun.lock ./
|
||||||
RUN npm install -g bun
|
RUN npm install -g bun
|
||||||
|
|||||||
@@ -1,36 +1,47 @@
|
|||||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
# Thoughts — Frontend
|
||||||
|
|
||||||
## Getting Started
|
Next.js 15 (App Router) frontend for the [Thoughts](../) self-hosted microblogging server.
|
||||||
|
|
||||||
First, run the development server:
|
## Features
|
||||||
|
|
||||||
|
- Post thoughts, reply, boost, and like
|
||||||
|
- Home feed, public feed, per-user timelines
|
||||||
|
- Browse and follow remote Fediverse actors by `@user@instance` handle
|
||||||
|
- Full remote actor profiles — bio, banner, profile fields, posts tab, followers/following tabs
|
||||||
|
- Full-text search for local users and thoughts; remote actor lookup via WebFinger
|
||||||
|
- Notifications, API key management, profile editing
|
||||||
|
- Dark/light theme
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
bun install
|
||||||
# or
|
|
||||||
yarn dev
|
|
||||||
# or
|
|
||||||
pnpm dev
|
|
||||||
# or
|
|
||||||
bun dev
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
Copy `.env.local.example` to `.env.local` (or set the variables directly):
|
||||||
|
|
||||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
```env
|
||||||
|
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||||
|
NEXT_PUBLIC_SERVER_SIDE_API_URL=http://localhost:8000
|
||||||
|
```
|
||||||
|
|
||||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
`NEXT_PUBLIC_API_URL` is used by client-side fetches (runs in the browser).
|
||||||
|
`NEXT_PUBLIC_SERVER_SIDE_API_URL` is used by server-side fetches (runs in Next.js SSR — can point to an internal service URL in Docker).
|
||||||
|
|
||||||
## Learn More
|
## Run
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
```bash
|
||||||
|
bun run dev # development — http://localhost:3000
|
||||||
|
bun run build # production build
|
||||||
|
bun run start # serve production build
|
||||||
|
```
|
||||||
|
|
||||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
## Docker
|
||||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
||||||
|
|
||||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
```bash
|
||||||
|
docker build \
|
||||||
## Deploy on Vercel
|
--build-arg NEXT_PUBLIC_API_URL=https://api.yourdomain.example.com \
|
||||||
|
--build-arg NEXT_PUBLIC_SERVER_SIDE_API_URL=http://thoughts:8000 \
|
||||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
-t thoughts-frontend .
|
||||||
|
docker run -p 3000:3000 thoughts-frontend
|
||||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user