diff --git a/.env.example b/.env.example index 17fb0b8..15e6bcf 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,8 @@ # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. # See the documentation for all the connection string options: https://pris.ly/d/connection-strings -# Enable to use different location for dev db file -# DATABASE_URL="file:./dev.db" +# Change to use different location for dev db file +DATABASE_URL="file:$HOME/.nsecbunker-config/nsecbunker.db" # Add your admin Nostr npub # ADMIN_NPUBS=npub1q2s369... diff --git a/README.md b/README.md index a998bc6..6de7431 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,15 @@ To quickly install `nsecbunkerd` via Docker just run: ### Configurations -Prepare your config directory +- Prepare your config directory + + ```shell + mkdir $HOME/.nsecbunker-config + ``` -```shell -mkdir $HOME/.nsecbunker-config -``` +- Clone `.env.example` and add your nostr public key to `ADMIN_NPUBS` to the `.env` file. -Clone `.env.example` and add your nostr public key to `ADMIN_NPUBS` to the `.env` file. +- Change `DATABASE_URL` if necessary. ```shell cp .env.example .env @@ -38,7 +40,7 @@ docker compose up -d ### Get the connection string ```shell -docker compose exec nsecbunkerd cat /app/connection.txt +docker compose exec nsecbunkerd cat /app/config/connection.txt ``` nsecBunker will give you a connection string like: diff --git a/docker-compose.yml b/docker-compose.yml index 3d620b6..d0241a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: volumes: - $HOME/.nsecbunker-config:/app/config env_file: - - .env.example + - .env ports: - "3000:3000" depends_on: @@ -22,7 +22,7 @@ services: volumes: - $HOME/.nsecbunker-config:/app/config env_file: - - .env.example + - .env restart: no entrypoint: "" command: diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 4bea2f9..e8b5344 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,11 +1,11 @@ generator client { provider = "prisma-client-js" - binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"] + binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"] } datasource db { provider = "sqlite" - url = "file:../config/nsecbunker.db" + url = env("DATABASE_URL") } model Request { diff --git a/src/config/index.ts b/src/config/index.ts index a638e2c..4c37c02 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -33,6 +33,7 @@ export interface IConfig { }; admin: IAdminOpts; authPort?: number; + authHost?: string; database: string; logs: string; keys: Record; @@ -49,6 +50,7 @@ const defaultConfig: IConfig = { ] }, authPort: 3000, + authHost: 'localhost', admin: { npubs: [], adminRelays: [ diff --git a/src/daemon/admin/index.ts b/src/daemon/admin/index.ts index 7902005..df42ab4 100644 --- a/src/daemon/admin/index.ts +++ b/src/daemon/admin/index.ts @@ -17,6 +17,8 @@ import fs from 'fs'; import { validateRequestFromAdmin } from './validations/request-from-admin'; import { dmUser } from '../../utils/dm-user'; import { IConfig, getCurrentConfig } from "../../config"; +import path from 'path'; + const debug = createDebug("nsecbunker:admin"); @@ -63,7 +65,8 @@ class AdminInterface { console.log(`\n\nnsecBunker connection string:\n\n${connectionString}\n\n`); // write connection string to connection.txt - fs.writeFileSync('connection.txt', connectionString); + const configFolder = path.dirname(configFile) + fs.writeFileSync(path.join(configFolder, 'connection.txt'), connectionString); this.signerUser = user; diff --git a/src/daemon/run.ts b/src/daemon/run.ts index ea672f1..ec5b16a 100644 --- a/src/daemon/run.ts +++ b/src/daemon/run.ts @@ -185,7 +185,7 @@ class Daemon { } }); - this.fastify.listen({ port: this.config.authPort }); + this.fastify.listen({ port: this.config.authPort, host: this.config.authHost }); this.fastify.get('/requests/:id', authorizeRequestWebHandler); this.fastify.post('/requests/:id', processRequestWebHandler);