mirror of
https://github.com/aljazceru/nsecbunkerd.git
synced 2025-12-17 06:04:22 +01:00
feat: cleanup docker setup
- Add .dockerignore - Replace .env with .env.example - Add migrations service - Cleanup Dockerfile: simpler setup, simpler copy, no migrations inside the image - Update README to match new instruction
This commit is contained in:
20
.dockerignore
Normal file
20
.dockerignore
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
node_modules/
|
||||||
|
.env
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.npmrc
|
||||||
|
.dockerignore
|
||||||
|
.DS_Store
|
||||||
|
npm-debug.log
|
||||||
|
logs/
|
||||||
|
tmp/
|
||||||
|
coverage/
|
||||||
|
dist/
|
||||||
|
*.md
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
|
Dockerfile
|
||||||
|
|
||||||
|
nsecbunker.json
|
||||||
|
connection.txt
|
||||||
|
config
|
||||||
@@ -4,4 +4,8 @@
|
|||||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
# 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
|
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||||
|
|
||||||
DATABASE_URL="file:./dev.db"
|
# Enable to use different location for dev db file
|
||||||
|
# DATABASE_URL="file:./dev.db"
|
||||||
|
|
||||||
|
# Add your admin Nostr npub
|
||||||
|
# ADMIN_NPUBS=npub1q2s369...
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ dist
|
|||||||
nsecbunker.json
|
nsecbunker.json
|
||||||
connection.txt
|
connection.txt
|
||||||
config
|
config
|
||||||
|
.env
|
||||||
|
|||||||
29
Dockerfile
29
Dockerfile
@@ -1,31 +1,26 @@
|
|||||||
FROM node:20-alpine AS build
|
FROM node:20.11-bullseye AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN apk update && \
|
|
||||||
apk add --no-cache openssl python3 make g++ \
|
|
||||||
&& ln -sf python3 /usr/bin/python
|
|
||||||
|
|
||||||
# Copy package files and install dependencies
|
# Copy package files and install dependencies
|
||||||
COPY package.json package-lock.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Copy application files
|
# Copy application files
|
||||||
COPY src/ src/
|
COPY . .
|
||||||
COPY scripts/ scripts/
|
|
||||||
COPY prisma/schema.prisma prisma/
|
|
||||||
COPY tsconfig.json ./
|
|
||||||
|
|
||||||
# Generate prisma client and build the application
|
# Generate prisma client and build the application
|
||||||
RUN npx prisma generate
|
RUN npx prisma generate
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
FROM node:20-alpine
|
FROM node:20.11-alpine as runtime
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add --no-cache openssl
|
apk add --no-cache openssl && \
|
||||||
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
# Copy built files from the build stage
|
# Copy built files from the build stage
|
||||||
COPY --from=build /app .
|
COPY --from=build /app .
|
||||||
@@ -33,11 +28,7 @@ COPY --from=build /app .
|
|||||||
# Install only runtime dependencies
|
# Install only runtime dependencies
|
||||||
RUN npm install --only=production
|
RUN npm install --only=production
|
||||||
|
|
||||||
# Copy and run migrations
|
EXPOSE 3000
|
||||||
COPY --from=build /app/prisma ./prisma
|
|
||||||
RUN npx prisma migrate deploy
|
|
||||||
RUN npx prisma db push
|
|
||||||
|
|
||||||
# Set entrypoint
|
ENTRYPOINT [ "node", "./dist/index.js" ]
|
||||||
ENTRYPOINT [ "node", "scripts/start.js" ]
|
|
||||||
CMD ["start"]
|
CMD ["start"]
|
||||||
|
|||||||
41
README.md
41
README.md
@@ -1,36 +1,44 @@
|
|||||||
# nsecbunkerd
|
# nsecbunkerd
|
||||||
Daemon to remotely sign nostr events using keys.
|
Daemon to remotely sign nostr events using keys.
|
||||||
|
|
||||||
## Easy setup via docker
|
## Easy setup via docker compose
|
||||||
|
|
||||||
To quickly install `nsecbunkerd` via Docker just run:
|
To quickly install `nsecbunkerd` via Docker just run:
|
||||||
|
|
||||||
### Prepare your config directory
|
### Configurations
|
||||||
```
|
|
||||||
|
Prepare your config directory
|
||||||
|
|
||||||
|
```shell
|
||||||
mkdir $HOME/.nsecbunker-config
|
mkdir $HOME/.nsecbunker-config
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Clone `.env.example` and add your nostr public key to `ADMIN_NPUBS` to the `.env` file.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
### Start nsecbunkerd
|
### Start nsecbunkerd
|
||||||
|
|
||||||
```
|
Create and start the project containers. This runs the migrations and then runs nsecbunkderd container.
|
||||||
docker run -d --name nsecbunkerd -v $HOME/.nsecbunker-config:/app/config pablof7z/nsecbunkerd start --admin <your-npub>
|
|
||||||
docker exec -i nsecbunkerd npx prisma db push
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Docker-compose
|
```shell
|
||||||
Edit `docker-compose.yml` and add your nostrpublic key in `command` directive, like `start --admin npub1nftkhktqglvcsj5n4wetkpzxpy4e5x78wwj9y9p70ar9u5u8wh6qsxmzqs`
|
# Optionally, build the image locally
|
||||||
|
docker compose build nsecbunkerd
|
||||||
|
|
||||||
And start the container
|
# Start the project
|
||||||
```
|
docker compose up
|
||||||
|
|
||||||
|
# Or in the background
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
docker compose exec nsecbunker npx prisma db push
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Get the connection string
|
### Get the connection string
|
||||||
|
|
||||||
```
|
```shell
|
||||||
docker exec nsecbunkerd cat /app/connection.txt
|
docker compose exec nsecbunkerd cat /app/connection.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
nsecBunker will give you a connection string like:
|
nsecBunker will give you a connection string like:
|
||||||
@@ -47,7 +55,7 @@ to find the options to add and approve keys from the CLI.
|
|||||||
|
|
||||||
Node.js v18 or newer is required.
|
Node.js v18 or newer is required.
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git clone <nsecbunkerd-repo>
|
git clone <nsecbunkerd-repo>
|
||||||
npm i
|
npm i
|
||||||
npm run build
|
npm run build
|
||||||
@@ -71,11 +79,12 @@ Note that ONLY the npub that you designated as an administrator when launching n
|
|||||||
Here you'll give nsecBunker your nsec. It will ask you for a passphrase to encrypt it on-disk.
|
Here you'll give nsecBunker your nsec. It will ask you for a passphrase to encrypt it on-disk.
|
||||||
The name is an internal name you'll use to refer to this keypair. Choose anything that is useful to you.
|
The name is an internal name you'll use to refer to this keypair. Choose anything that is useful to you.
|
||||||
|
|
||||||
```
|
```shell
|
||||||
npm run nsecbunkerd -- add --name <your-key-name>
|
npm run nsecbunkerd -- add --name <your-key-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm run nsecbunkerd -- add --name "Uncomfortable family"
|
$ npm run nsecbunkerd -- add --name "Uncomfortable family"
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,32 @@
|
|||||||
version: "3.3"
|
version: "3.3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nsecbunkerd:
|
nsecbunkerd:
|
||||||
image: nsecbunkerd
|
image: pablof7z/nsecbunkerd
|
||||||
build: .
|
build: .
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
pids_limit: 50
|
pids_limit: 100
|
||||||
mem_limit: 256mb
|
mem_limit: 256mb
|
||||||
memswap_limit: 256mb
|
memswap_limit: 256mb
|
||||||
volumes:
|
volumes:
|
||||||
- ./nsecbunker-config:/app/config
|
- $HOME/.nsecbunker-config:/app/config
|
||||||
command: start --admin <npub>
|
env_file:
|
||||||
|
- .env.example
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
depends_on:
|
||||||
|
- migrations
|
||||||
|
|
||||||
|
migrations:
|
||||||
|
image: pablof7z/nsecbunkerd
|
||||||
|
volumes:
|
||||||
|
- $HOME/.nsecbunker-config:/app/config
|
||||||
|
env_file:
|
||||||
|
- .env.example
|
||||||
|
restart: no
|
||||||
|
entrypoint: ""
|
||||||
|
command:
|
||||||
|
- npx
|
||||||
|
- prisma
|
||||||
|
- migrate
|
||||||
|
- deploy
|
||||||
|
|||||||
Reference in New Issue
Block a user