nip-05
This commit is contained in:
1
packages/nostr/docker/relay/.dockerignore
Normal file
1
packages/nostr/docker/relay/.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
1
packages/nostr/docker/relay/.gitignore
vendored
Normal file
1
packages/nostr/docker/relay/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
12
packages/nostr/docker/relay/Dockerfile
Normal file
12
packages/nostr/docker/relay/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM scsibug/nostr-rs-relay
|
||||
|
||||
USER root
|
||||
RUN apt-get update && apt-get install -y curl nodejs npm
|
||||
RUN npm i -g yarn
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
COPY . .
|
||||
USER $APP_USER
|
||||
RUN yarn
|
||||
CMD ["/bin/bash", "-c", "while :; do yarn app /bin/bash -c 'rm -rf /usr/src/app/db/* && ./nostr-rs-relay --db /usr/src/app/db --config ./config.toml'; done;"]
|
11
packages/nostr/docker/relay/config.toml
Normal file
11
packages/nostr/docker/relay/config.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[info]
|
||||
relay_url = "wss://nostr.example.com/"
|
||||
name = "nostr-rs-relay"
|
||||
description = "nostr-rs-relay description"
|
||||
contact = "mailto:contact@example.com"
|
||||
favicon = "favicon.ico"
|
||||
|
||||
[authorization]
|
||||
nip42_auth = true
|
||||
# This seems to have no effect.
|
||||
nip42_dms = true
|
26
packages/nostr/docker/relay/index.ts
Normal file
26
packages/nostr/docker/relay/index.ts
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Allows the relay to be shut down with an HTTP request, after which
|
||||
* docker-compose will restart it. This allows each test to have a clean
|
||||
* slate. The drawback is that the tests can't run in parallel, so the
|
||||
* test suite is very slow. A better option would be to have this relay
|
||||
* server manage the relay completely: star/stop isolated relay instances
|
||||
* with HTTP requests and allow multiple instances to run at the same
|
||||
* time so that the tests can be parallelized.
|
||||
*/
|
||||
|
||||
import http from "node:http"
|
||||
import { spawn } from "node:child_process"
|
||||
|
||||
const child = spawn(process.argv[2], process.argv.slice(3), {
|
||||
stdio: "inherit",
|
||||
})
|
||||
|
||||
const server = http.createServer((_, res) => {
|
||||
if (!child.kill(9)) {
|
||||
console.error("killing the subprocess failed")
|
||||
}
|
||||
res.end()
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
server.listen(8000)
|
14
packages/nostr/docker/relay/package.json
Normal file
14
packages/nostr/docker/relay/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "relay",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"app": "ts-node index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^18.15.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
4
packages/nostr/docker/well-known/Dockerfile
Normal file
4
packages/nostr/docker/well-known/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
# An nginx server to return a .well-known/nostr.json file for testing.
|
||||
FROM nginx
|
||||
RUN mkdir /usr/share/nginx/html/.well-known
|
||||
COPY nostr.json /usr/share/nginx/html/.well-known/nostr.json
|
10
packages/nostr/docker/well-known/nostr.json
Normal file
10
packages/nostr/docker/well-known/nostr.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"names": {
|
||||
"bob": "be4be3c0c4f2d18f11215087d7d18fad2c9e0269fc50e19d526bdfb11a522a64"
|
||||
},
|
||||
"relays": {
|
||||
"be4be3c0c4f2d18f11215087d7d18fad2c9e0269fc50e19d526bdfb11a522a64": [
|
||||
"ws://example.com"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user