diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..126f8d8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +## 1.0.0 (2023-09-29) + + +### Features + +* add heath check and docker file ([3e55899](https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper/commit/3e55899be0f54aa24045680fc976ed3ac91343f5)) + + +### Trivial Changes + +* add empty test ([ae4eb17](https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper/commit/ae4eb17bb8e21ed13a64d664dbc3b024f4f9e7b3)) +* commit package-lock.json ([ac4bcb4](https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper/commit/ac4bcb4c3049aac8b2fb24a2915452694530282d)) +* fix linting ([961d505](https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper/commit/961d505f1c22fe0ae03d233158e2f650f412f9df)) +* inital import ([d030766](https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper/commit/d0307667757a3b3b8c7af7388b26e06045b7b466)) diff --git a/Dockerfile b/Dockerfile index 1ac40a4..798e99f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,5 @@ COPY package*.json . RUN npm ci --quiet COPY . . RUN npm run build -RUN npm link ENTRYPOINT [ "node", "dist/src/index.js" ] + diff --git a/README.md b/README.md index ccfe60a..208e752 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,9 @@ Rust bootstrapper: https://github.com/libp2p/rust-libp2p/tree/master/misc/server ## Start the bootstrapper ```console -$ npx @libp2p/amino-dht-bootstrapper +$ npx @libp2p/amino-dht-bootstrapper amino ``` -### Configuring bootstrapper options - ```sh Options: --config Path to IPFS config file @@ -50,6 +48,39 @@ Options: -h, --help Print help ``` +### Configuring bootstrapper options + +``` +{ + "config": { + "description": "Path to IPFS config file", + "type": "string" + }, + "enableKademlia": { + "description": "Whether to run the libp2p Kademlia protocol and join the IPFS DHT", + "type": "boolean" + }, + "enableAutonat": { + "description": "Whether to run the libp2p Autonat protocol", + "type": "boolean" + }, + "metricsPath": { + "description": "Metric endpoint path", + "default": "/metrics", + "type": "string" + }, + "metricsPort": { + "description": "Port to serve metrics", + "default": "8888", + "type": "string" + }, + "help": { + "description": "Show help text", + "type": "boolean" + } +} +``` + ## Building the Docker Image Building should be straightforward from the root of the repository: diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml new file mode 100644 index 0000000..8604b0d --- /dev/null +++ b/docker-compose.dev.yaml @@ -0,0 +1,10 @@ +services: + bootstrapper: + build: + context: ./ + dockerfile: Dockerfile + ports: + - 8888:8888 + environment: + - CONFIG_FLAGS="" + command: node dist/src/index.js diff --git a/package-lock.json b/package-lock.json index a9d7b77..454718d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@libp2p/amino-dht-bootstrapper", - "version": "0.0.0", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@libp2p/amino-dht-bootstrapper", - "version": "0.0.0", + "version": "1.0.0", "license": "Apache-2.0 OR MIT", "dependencies": { "@chainsafe/libp2p-noise": "^13.0.1", diff --git a/package.json b/package.json index e238925..68955ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/amino-dht-bootstrapper", - "version": "0.0.0", + "version": "1.0.0", "description": "Run an Amino DHT boostrapper with js-libp2p", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p-amino-dht-bootstrapper#readme", diff --git a/src/index.ts b/src/index.ts index f9be570..9320ece 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,41 +16,43 @@ import { circuitRelayServer } from 'libp2p/circuit-relay' import { register } from 'prom-client' async function main (): Promise { + const options = { + config: { + description: 'Path to IPFS config file', + type: 'string' + }, + enableKademlia: { + description: 'Whether to run the libp2p Kademlia protocol and join the IPFS DHT', + type: 'boolean' + }, + enableAutonat: { + description: 'Whether to run the libp2p Autonat protocol', + type: 'boolean' + }, + metricsPath: { + description: 'Metric endpoint path', + default: '/metrics', + type: 'string' + }, + metricsPort: { + description: 'Port to serve metrics', + default: '8888', + type: 'string' + }, + help: { + description: 'Show help text', + type: 'boolean' + } + } as const + const args = parseArgs({ allowPositionals: true, strict: true, - options: { - help: { - description: 'Show help text', - type: 'boolean' - }, - config: { - description: 'Path to IPFS config file', - type: 'string' - }, - metricsPath: { - description: 'Metric endpoint path', - default: '/metrics', - type: 'string' - }, - metricsPort: { - description: 'Port to serve metrics', - default: '8888', - type: 'string' - }, - enableKademlia: { - description: 'Whether to run the libp2p Kademlia protocol and join the IPFS DHT', - type: 'boolean' - }, - enableAutonat: { - description: 'Whether to run the libp2p Autonat protocol', - type: 'boolean' - } - } + options }) if (args.values.help === true) { - console.info('Help!') + console.info(JSON.stringify(options, null, 2)) return } @@ -96,7 +98,8 @@ async function main (): Promise { res.end('Not Found') } }) - await new Promise((resolve) => metricsServer.listen(parseInt(args.values.metricsPort ?? '8888', 10), '0.0.0.0', resolve)) + const port = parseInt(args.values.metricsPort ?? options.metricsPort.default, 10) + await new Promise((resolve) => metricsServer.listen(port, '0.0.0.0', resolve)) console.info('Metrics server listening', `0.0.0.0:${args.values.metricsPort}/${args.values.metricsPath}`) }