Skip to content

Commit 65f45c8

Browse files
author
pluja
committed
initial commit
0 parents  commit 65f45c8

35 files changed

+3932
-0
lines changed

.github/workflows/nerostr-docker.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docker Image CI
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v2
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v2
22+
23+
- name: Login to DockerHub
24+
uses: docker/login-action@v2
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_TOKEN }}
28+
29+
- name: Build and push Docker image
30+
uses: docker/build-push-action@v4
31+
with:
32+
context: ./nerostr
33+
file: Dockerfile
34+
platforms: linux/amd64,linux/arm64
35+
push: true
36+
tags: |
37+
${{ format('{0}/nerostr:{1}', secrets.DOCKERHUB_USERNAME, github.event.release.tag_name) }}
38+
${{ format('{0}/nerostr:latest', secrets.DOCKERHUB_USERNAME) }}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Check for new tags and build Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
check-and-build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Check for new tags in hoytech/strfry
17+
run: |
18+
#!/bin/bash
19+
latest_tag=$(curl -s https://api.github.com/repos/hoytech/strfry/tags | jq -r '.[0].name')
20+
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
21+
22+
- name: Check if the new tag exists in DockerHub
23+
id: check-tag
24+
run: |
25+
#!/bin/bash
26+
dockerhub_tags=$(curl -s https://hub.docker.com/v2/repositories/${{ secrets.DOCKERHUB_USERNAME }}/strfry/tags | jq -r '.results[].name')
27+
if echo "${dockerhub_tags}" | grep -q "${{ env.latest_tag }}"; then
28+
echo "::set-output name=exists::true"
29+
else
30+
echo "::set-output name=exists::false"
31+
fi
32+
33+
- name: Set up QEMU
34+
if: steps.check-tag.outputs.exists == 'false'
35+
uses: docker/setup-qemu-action@v2
36+
37+
- name: Set up Docker Buildx
38+
if: steps.check-tag.outputs.exists == 'false'
39+
uses: docker/setup-buildx-action@v2
40+
41+
- name: Login to DockerHub
42+
if: steps.check-tag.outputs.exists == 'false'
43+
uses: docker/login-action@v2
44+
with:
45+
username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
48+
- name: Clone hoytech/strfry
49+
if: steps.check-tag.outputs.exists == 'false'
50+
run: git clone https://github.com/hoytech/strfry strfry-hoytech
51+
52+
- name: Build and push Docker image from hoytech/strfry
53+
if: steps.check-tag.outputs.exists == 'false'
54+
uses: docker/build-push-action@v4
55+
with:
56+
context: ./strfry-hoytech
57+
file: Dockerfile
58+
platforms: linux/amd64,linux/arm64
59+
push: true
60+
tags: |
61+
${{ format('{0}/strfry:{1}', secrets.DOCKERHUB_USERNAME, env.latest_tag) }}
62+
${{ format('{0}/strfry:latest', secrets.DOCKERHUB_USERNAME) }}
63+
strfry:latest
64+
65+
- name: Build and push Docker image
66+
if: steps.check-tag.outputs.exists == 'false'
67+
uses: docker/build-push-action@v4
68+
with:
69+
context: ./strfry
70+
file: Dockerfile
71+
platforms: linux/amd64,linux/arm64
72+
push: true
73+
tags: |
74+
${{ format('{0}/nerostr-strfry:{1}', secrets.DOCKERHUB_USERNAME, env.latest_tag) }}
75+
${{ format('{0}/nerostr-strfry:latest', secrets.DOCKERHUB_USERNAME) }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
nerostr/nerostr_data/db
3+
nerostr_data
4+
wallet
5+
strfry-db
6+
.env
7+
*.override.yml
8+
nerostr/html/static/style.css.fiber.gz

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# nerostr: a nostr monero-paid relay
2+
3+
Everyone is free to read, but only paid users can publish events.
4+
5+
**A Nostr expensive relay paid with Monero and written in Go!**
6+
7+
- Check it out here: https://xmr.usenostr.org
8+
- Add the expensive relay to your list: `wss://xmr.usenostr.org`.
9+
10+
## Features
11+
12+
- Very easy to self-host.
13+
- Lightweight and fast.
14+
- Uses `strfry` nostr relay, which is a very fast and efficient relay.
15+
- Uses `badgerdb` as a database, which is a fast and efficient golang database.
16+
- Talks directly with the `monero-wallet-rpc` to check for payments and get subaddresses.
17+
- Simple UI written using Golang templates and TailwindCSS.
18+
19+
## Why?
20+
21+
Nostr has no spam filters/control. With public relays, the global feed and public chat channels get filled with spam, making them unusable.
22+
23+
In order to avoid spam in your feed, you pay a small fee (~$1) to a relay. Your pubkey gets whitelisted in that relay, and then you are able to publish events there. Reading from these relays is always free for everyone! This allows getting much more curated and clean results in the global page.
24+
25+
Also, paid relays can build up communities of users interested in particular topics, allowing users to follow relays based on their interests.
26+
27+
TLDR; Pay-to-relay to avoid nostr spammers.
28+
29+
## Self-hosting your own relay
30+
31+
Selfhosting a Nerostr relay is very easy, you just need a small server and Docker.
32+
33+
1. Get the `docker-compose.yml` file from this repo.
34+
35+
```bash
36+
wget https://raw.githubusercontent.com/pluja/nerostr/master/docker-compose.yml
37+
```
38+
39+
2. Create a new Monero wallet, get the `wallet` and `wallet.keys` files and put them in `./nerostr_data/wallet/` folder.
40+
- You can use the `monero-wallet-cli` to create a new wallet, or use [Feather Wallet](https://moneroaddress.org/) for a GUI wallet.
41+
42+
3. Get the `.env` file from this repo and modify all the variables to your needs. Mainly you will have to edit the `MONERO_WALLET_FILENAME` and `MONERO_WALLET_PASSWORD` variables.
43+
44+
```bash
45+
wget -o .env https://raw.githubusercontent.com/pluja/nerostr/master/example.env
46+
```
47+
48+
4. Get the config file for your the `strfry` relay:
49+
50+
```bash
51+
wget -o strfry.conf https://raw.githubusercontent.com/pluja/nerostr/master/strfry/strfry.conf
52+
```
53+
54+
::: warning
55+
You can change the `strfry` config as you want, but you must make sure to have the `plugin = "/app/nerostr-auth.sh"` line in the `writePolicy` section. If you don't have this, the paywall won't do anything and all events will be accepted by the relay.
56+
:::
57+
58+
## How does it work?
59+
60+
Users go to the `paywall` frontend, enter their `pubkey` either in npub or hex format, and pay a small fee in Monero. Once paid, their pubkey gets added to the whitelist database.
61+
62+
The `strfry` relay uses the nerostr-auth plugin to check if the pubkey of the user is in the whitelist database. If it is, the event gets accepted and published. If it is not, the event gets rejected.
63+
64+
The payment monitor talks directly with the `monero-wallet-rpc` to check for payments.
65+
66+
## 🧡 Support this project
67+
68+
[kycnot.me/about#support](https://kycnot.me/about#support)

docker-compose.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: "3.9"
2+
3+
services:
4+
strfry-nerostr-relay:
5+
container_name: nerostr-strfry-relay
6+
image: pluja/nerostr-strfry:latest
7+
environment:
8+
- API_URL=http://nerostr:8080
9+
volumes:
10+
- ./strfry.conf:/etc/strfry.conf
11+
- ./nerostr_data/strfry/strfry-db:/app/strfry-db
12+
13+
monero-wallet-rpc:
14+
container_name: nerostr-monero-wallet-rpc
15+
env_file:
16+
- .env
17+
image: sethsimmons/simple-monero-wallet-rpc:latest
18+
command: [
19+
"--wallet-file",
20+
"/home/monero/${MONERO_WALLET_FILENAME}",
21+
"--password",
22+
"${MONERO_WALLET_PASSWORD}",
23+
"--rpc-bind-port",
24+
"28081",
25+
"--daemon-host",
26+
"${MONERO_DAEMON_RPC_HOSTNAME}",
27+
"--daemon-port",
28+
"${MONERO_DAEMON_RPC_PORT}",
29+
"--disable-rpc-login",
30+
"--max-log-files",
31+
"1",
32+
"--max-log-file-size",
33+
"1000000"
34+
]
35+
volumes:
36+
- ./nerostr_data/wallet/:/home/monero/
37+
restart: unless-stopped
38+
ports:
39+
- 28081:28081
40+
41+
nerostr:
42+
container_name: nerostr-paywall
43+
image: pluja/nerostr:latest
44+
env_file:
45+
- .env
46+
volumes:
47+
- ./nerostr_data/nerostr/nerostr-db:/app/nerostr_data/db
48+
ports:
49+
- "8089:8080"
50+
depends_on:
51+
- strfry-nerostr-relay
52+
- monero-wallet-rpc

example.env

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
##############
2+
# MONERO RPC #
3+
##############
4+
# The RPC server address of the Monero daemon
5+
MONERO_DAEMON_RPC_HOSTNAME=node.community.rino.io
6+
# The RPC server port of the Monero daemon
7+
MONERO_DAEMON_RPC_PORT=18081
8+
# The filename of your Monero wallet (wallet_file and wallet_file.keys)
9+
MONERO_WALLET_FILENAME=wallet_file
10+
# The password for your Monero wallet
11+
MONERO_WALLET_PASSWORD=123
12+
13+
#############
14+
# NEROSTR #
15+
#############
16+
# (OPTIONAL VARS)
17+
18+
# Admission fee in XMR, default is 0.002
19+
# ADMISSION_AMOUNT=0.005
20+
21+
# The time before an invoice is considered expired, default is 3600 seconds
22+
# INVOICE_EXPIRE_TIME=7200

nerostr/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
style.css
2+
nerostr_data
3+
node_modules

nerostr/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM devopsworks/golang-upx:latest as builder
2+
WORKDIR /app
3+
COPY . .
4+
RUN go mod tidy
5+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o nerostr . && \
6+
upx nerostr
7+
RUN chmod +x nerostr
8+
9+
# Tailwind CSS compiler
10+
FROM node:latest as tailwind
11+
WORKDIR /app
12+
COPY ./package.json .
13+
COPY ./package-lock.json .
14+
COPY ./tailwind.config.js .
15+
COPY ./html /app/html
16+
RUN npm install && \
17+
npx tailwindcss -o ./style.css --minify
18+
19+
FROM alpine:latest as certs
20+
RUN apk --update add ca-certificates
21+
22+
FROM scratch
23+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
24+
WORKDIR /app
25+
COPY ./html/ /app/html/
26+
COPY --from=tailwind /app/style.css /app/html/static/style.css
27+
COPY --from=builder /app/nerostr /bin/usr/nerostr
28+
ENV PATH="/bin/usr:${PATH}"
29+
ENTRYPOINT ["nerostr"]

0 commit comments

Comments
 (0)