chore: add start/stop scripts

This commit is contained in:
Ricardo Arturo Cabral Mejía 2022-12-20 23:05:12 -05:00
parent 5edfc04d77
commit bb08f7637d
7 changed files with 51 additions and 33 deletions

View File

@ -87,42 +87,25 @@ Clone repository and enter directory:
cd nostr-ts-relay
```
Start with:
Start:
```
npm run docker:compose:start -- --detach
./scripts/start
```
or
```
./scripts/start_with_tor
```
Stop the server with:
```
npm run docker:compose:stop
```
## Quick Start (over Tor)
`Docker` `Tor`
Install Docker following the [official guide](https://docs.docker.com/engine/install/).
You may have to uninstall Docker if you installed it using a different guide.
Clone repository and enter directory:
```
git clone git@github.com:Cameri/nostr-ts-relay.git
cd nostr-ts-relay
```
Start with:
```
npm run tor:docker:compose:start
./scripts/stop
```
Print the Tor hostname:
```
npm run tor:hostname
./scripts/print_tor_hostname
```
Stop the server with:
```
npm run tor:docker:compose:stop
```
## Quick Start (Standalone)

View File

@ -37,14 +37,12 @@
"pretest:integration": "mkdir -p .test-reports/integration",
"test:integration": "cucumber-js",
"cover:integration": "nyc --report-dir .coverage/integration npm run test:integration -- -p cover",
"predocker:compose:start": "[ -d \"$PWD/.nostr\" ] || mkdir -p $PWD/.nostr",
"docker:compose:start": "docker compose up --build --remove-orphans",
"docker:compose:stop": "docker compose down",
"docker:compose:clean": "docker compose rm",
"pretor:docker:compose:start": "mkdir -p $PWD/.nostr/tor/data",
"tor:docker:compose:start": "docker compose -f docker-compose.yml -f docker-compose.tor.yml up --build --remove-orphans",
"tor:hostname": "cat $PWD/.nostr/tor/data/nostr-ts-relay/hostname",
"tor:docker:compose:stop": "docker compose -f docker-compose.yml -f docker-compose.tor.yml down",
"docker:compose:start": "./scripts/start",
"docker:compose:stop": "./scripts/stop",
"docker:compose:clean": "./scripts/clean",
"tor:docker:compose:start": "./scripts/start_with_tor",
"tor:hostname": "./scripts/print_tor_hostname",
"tor:docker:compose:stop": "./scripts/stop",
"docker:integration:run": "docker compose -f ./test/integration/docker-compose.yml run --rm tests",
"docker:test:integration": "npm run docker:integration:run -- npm run test:integration",
"docker:cover:integration": "npm run docker:integration:run -- npm run cover:integration",

8
scripts/clean Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
$PROJECT_ROOT/scripts/stop_docker
docker system prune
docker volume prune

4
scripts/print_tor_hostname Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
cat $PROJECT_ROOT/.nostr/tor/data/nostr-ts-relay/hostname

7
scripts/start Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
docker compose \
-f $DOCKER_COMPOSE_FILE \
up --build --remove-orphans $@

9
scripts/start_with_tor Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
DOCKER_COMPOSE_TOR_FILE="${PROJECT_ROOT}/docker-compose.tor.yml"
docker compose \
-f $DOCKER_COMPOSE_FILE \
-f $DOCKER_COMPOSE_TOR_FILE \
up --build --remove-orphans $@

9
scripts/stop Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
DOCKER_COMPOSE_TOR_FILE="${PROJECT_ROOT}/docker-compose.tor.yml"
docker compose \
-f $DOCKER_COMPOSE_FILE \
-f $DOCKER_COMPOSE_TOR_FILE \
down $@