new readme with contribution awards (#922)

* new readme

* Update README.md

* Update README.md

* move more docs to README

* add proper mapping for opensearch item index

* add sndev lint

* fix index creation
This commit is contained in:
Keyan 2024-03-15 14:29:42 -05:00 committed by GitHub
parent 687012d1a0
commit efaa2193e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 387 additions and 273 deletions

390
README.md
View File

@ -1,46 +1,382 @@
# contributing
We pay sats for PRs. Sats will be proportional to the impact of the PR. If there's something you'd like to work on, suggest how much you'd do it for on the issue. If there's something you'd like to work on that isn't already an issue, whether its a bug fix or a new feature, create one.
<p align="center">
<a href="https://stacker.news">
<img height="50" alt="Internet Communities with Bitcoin Economies" src="https://private-user-images.githubusercontent.com/34140557/313019203-bea58059-f850-4d4e-b52d-7e24bc307c8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA0NTgwNjMsIm5iZiI6MTcxMDQ1Nzc2MywicGF0aCI6Ii8zNDE0MDU1Ny8zMTMwMTkyMDMtYmVhNTgwNTktZjg1MC00ZDRlLWI1MmQtN2UyNGJjMzA3YzhjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE0VDIzMDkyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1NWI5YzM4YjA2YjI3Yzc3YzkzNmMwMDMwOWY1MDUwZjk5NTdiYTZjNzEzMDcxZGRmY2FlYzM3ZjFjOGM2M2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iW6d6aX_GErW7EY81p7PA2iVg9OhvGSoTwJC4VTvrCk">
</a>
</p>
We aim to have a quick PR turnaround time, but we are sometimes slower than we'd like. In most cases, if your PR is unambiguously good, it shouldn't take us more than 1 week.
- Stacker News makes Bitcoin economies
- What You See is What We Ship (look ma, I invented an initialism)
- 100% FOSS
- We pay bitcoin for PRs, issues, documentation, code reviews and more
- Next.js, postgres, graphql, and lnd
If you have a question about contributing start a [discussion](https://github.com/stackernews/stacker.news/discussions).
<br>
# responsible disclosure
# Getting started
If you found a vulnerability, we would greatly appreciate it if you contact us via [kk@stacker.news](mailto:kk@stacker.news) or t.me/k00bideh.
Launch a fully featured SN development environment in a single command.
# stacker.news
[Stacker News](https://stacker.news) is like Hacker News but we pay you Bitcoin. We use Bitcoin and the Lightning Network to provide Sybil resistance and any karma earned is withdrawable as Bitcoin.
```txt
$ ./sndev start
```
# wen decentralization
We're experimenting with providing an SN-like service on nostr in [Outer Space](https://outer.space). It's our overarching goal to align SN with Bitcoin's ethos yet still make a product the average bitcoiner loves to use.
Go to [localhost:3000](http://localhost:3000).
# local development
1. [Install docker-compose](https://docs.docker.com/compose/install/) and deps if you don't already have it installed
2. `git clone git@github.com:stackernews/stacker.news.git sn && cd sn`
3. `docker-compose up --build`
<br>
You should then be able to access the site at `localhost:3000` and any changes you make will hot reload. If you want to login locally or use lnd you'll need to modify `.env.sample` appropriately. More details [here](./docs/local-auth.md) and [here](./docs/local-lnd.md). If you have trouble please open an issue so I can help and update the README for everyone else.
## Installation
# web push
- Clone the repo
- ssh: `git clone git@github.com:stackernews/stacker.news.git`
- https: `git clone https://github.com/stackernews/stacker.news.git`
- Install [docker](https://docs.docker.com/get-docker/)
<br>
## Usage
Start the development environment
```txt
$ ./sndev start
```
View all available commands
```txt
$ ./sndev help
888
888
888
.d8888b 88888b. .d88888 .d88b. 888 888
88K 888 '88b d88' 888 d8P Y8b 888 888
'Y8888b. 888 888 888 888 88888888 Y88 88P
X88 888 888 Y88b 888 Y8b. Y8bd8P
88888P' 888 888 'Y88888 'Y8888 Y88P
manages a docker based stacker news development environment
USAGE
$ sndev [COMMAND]
$ sndev help [COMMAND]
COMMANDS
help show help
env:
start start env
stop stop env
restart restart env
status status of env
delete delete env
sn:
login login as a nym
lnd:
fund pay a bolt11 for funding
withdraw create a bolt11 for withdrawal
db:
psql open psql on db
prisma run prisma commands
dev:
pr fetch and checkout a pr
lint run linters
other:
compose docker compose passthrough
sn_lncli lncli passthrough on sn_lnd
stacker_lncli lncli passthrough on stacker_lnd
```
<br>
# Table of Contents
- [Getting started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [We pay bitcoin for contributions](#we-pay-bitcoin-for-contributions)
- [Pull request awards](#pull-request-awards)
- [Code review awards](#code-review-awards)
- [Issue specification awards](#issue-specification-awards)
- [Responsible disclosure of security or privacy vulnerability awards](#responsible-disclosure-of-security-or-privacy-vulnerability-awards)
- [Development documentation awards](#development-documentation-awards)
- [Helpfulness awards](#helpfulness-awards)
- [Development Tips](#development-tips)
- [Linting](#linting)
- [Database migrations](#database-migrations)
- [Connecting to the local database](#connecting-to-the-local-database)
- [Running lncli on the local lnd nodes](#running-lncli-on-the-local-lnd-nodes)
- [Testing local auth](#testing-local-auth)
- [Login with Email](#login-with-email)
- [Login with Github](#login-with-github)
- [Login with Lightning](#login-with-lightning)
- [Enabling web push notifications](#enabling-web-push-notifications)
- [Internals](#internals)
- [Stack](#stack)
- [Services](#services)
- [Wallet transaction safety](#wallet-transaction-safety)
- [Need help?](#need-help)
- [Responsible Disclosure](#responsible-disclosure)
- [License](#license)
<br>
# Contributing
We want your help.
<br>
## We pay bitcoin for contributions
- pull requests closing existing issues
- code review
- issue specification whether for bugs, features, or enhancements
- discovery of security vulnerabilities
- discovery of privacy vulnerabilities
- improvements to development documentation
- helpfulness
<br>
## Just in case
*This document in no way legally entitles you to payments for contributions, entitles you to being a contributor, or entitles you to the attention of other contributors. This document lays out the system we **can** use to determine contribution awards which we generally intend to abide by but importantly we reserve the right to refuse payments or contributions, modify rules and award amounts, make exceptions to rules or reward amounts, and withhold awards for any reason at anytime, even just for the heck of it, at our sole discretion. If you need more certainty than what I've just described, don't participate. We provide awards as an experiment to make FOSS less sucky.*
<br>
## Pull request awards
### Rules
1. PRs closing an issue will be awarded according to the `difficulty` tag on an issue, e.g. `difficulty:easy` pays 100k sats.
2. Issues are occasionally marked with a `priority` tag which multiplies the award of a PR closing an issue, e.g. an issue marked with `priority:high` and `difficulty:hard` awards 2m sats.
3. An award is reduced by 10% of the award amount for each substantial change requested to the PR on code review, e.g. if two changes are requested on a PR closing an issue tagged with `difficulty:hard`, 800k sats will be awarded.
- Reductions are applied before `priority` multipliers, e.g. a PR closing a `priority:high` and `difficulty:hard` issue that's approved after two changes are requested awards 1.6m sats.
- You are responsible for understanding the issue and requirements before requesting review on a PR.
- There is no award reduction for asking specific questions on the issue itself or on the PR before requesting review
- There is no award reduction for asking more general questions in a discussion
4. A PR must be merged by an SN engineer before a PR receives an award
### Difficulty award amounts
| tag | description | award |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
| `difficulty:good-first-issue` | at most a couple lines of code in a couple files and does not require much familiarity with the codebase | `20k sats` |
| `difficulty:easy` | at most a couple lines of code in a couple files but does require familiarity with the code base | `100k sats` |
| `difficulty:medium` | more code, more places and could require adding columns in the db and some modification chunky db queries | `250k sats` |
| `difficulty:medium-hard` | even more code, even more places and requires either more sophisticated logic, more significant db modeling eg adding a table, and/or a deeper study of a something | `500k sats` |
| `difficulty:hard` | either a bigger lift than the what's required of medium-hard or very tricky in a particular way that might not require a lot of code but does require a lot of context/troubleshooting/expertise | `1m sats` |
### Priority multipliers
| tag | multiplier |
| ----------------- | ---------- |
| `priority:medium` | 1.5 |
| `priority:high` | 2 |
| `priority:urgent` | 3 |
<br>
## Code review awards
Code reviewers will be awarded the amount their code review reduced from the PR author's reward, e.g. two substantial problems/areas of improvement identified in a PR closing a `priority:high` and `difficulty:hard` issue awards 400k sats.
### Rules
1. The problem or improvement must be acknowledged as such by SN engineers explicitly
2. A PR must be merged by an SN engineer before a PR's code reviewers receive an award
Code review approvals are more than welcome, but we can't guarantee awards for them because the work performed to approve a PR is unverifiable.
<br>
## Issue specification awards
Issue specifiers will be awarded up to 10% of a PR award for issues resulting in a PR being merged by an SN engineer that closes the issue. In addition to being subject to PR award amounts and reductions, specification amounts are awarded on the basis of how much additional help and specification is required by other contributors.
### Rules
1. The issue must directly result in PR being merged by an SN engineer that closes the issue
2. Issue specification award amounts are based on the final PR award amounts
- that is, they are subject to PR award code review reductions and priority multipliers
3. Award amounts will be reduced on the basis of how much additional help and specification is required by other contributors
4. Issue specifiers who can close their own issues with their own PRs are also eligible for this 10%
- e.g an issue tagged as `difficulty:hard` that is both specified and closed by a PR from the same contributor without changes requested awards 1.1m sats
### Relative awards
| circumstances | award |
| ---------------------------------------------------------------------------------------------------------- | ----- |
| issue doesn't require further help and/or specification from other contributors | 10% |
| issue requires little help and/or specification from other contributors | 5% |
| issue requires more help and/or specification from other contributors than the issue specifier contributed | 1% |
| issue is vague and/or incomplete and must mostly be entirely specified by someone else | 0% |
For example: a specified issue that's tagged as `difficulty:hard`, doesn't require additional specification and disambiguation by other contributors, and results in PR being merged without changes requested awards the issue specifier 100k sats.
<br>
## Responsible disclosure of security or privacy vulnerability awards
Awards for responsible disclosures are assessed on the basis of:
1. the potential loss resulting from an exploit of the vulnerability
2. the trivialness of exploiting the vulnerability
3. the disclosure's detail
Award amounts will be easiest to assess on a case by case basis. Upon confirmation of a vulnerability, we agree to award responsible disclosures at minimum 100k sats and as high as the total potential loss that would result from exploiting the vulnerability.
### Rules
1. Disclosure is responsible and does not increase the likelihood of an exploit
2. Disclosure details how to exploit the vulnerability with certainty
<br>
## Development documentation awards
For significant changes to documentation, create an issue before making said changes. In such cases we will award documentation improvements in accordance with issue specification and PR awards.
For changes on the order of something like a typo, we'll award a nominal amount at our discretion.
<br>
## Helpfulness awards
Like issue specification awards, helping fellow contributors substantially in a well documented manner such that the helped fellow contributes a merged PR is eligible for a one-time relative reward.
| circumstances | award |
| -------------------------------------------------------------------------------------- | ----- |
| substantial and singular source of help | 10% |
| substantial but nonsingular source of help | 1-5% |
| source of relatively trivial help | 1% |
<br>
# Development Tips
<br>
## Linting
We use [JavaScript Standard Style](https://standardjs.com/) to enforce code style and correctness. You should run `sndev lint` before submitting a PR.
If you're using VSCode, you can install the [StandardJS VSCode Extension](https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard) extension to get linting in your editor. We also recommend installing [StandardJS code snippets](https://marketplace.visualstudio.com/items?itemName=capaj.vscode-standardjs-snippets) and [StandardJS react code snippets](https://marketplace.visualstudio.com/items?itemName=TimonVS.ReactSnippetsStandard) for code snippets.
<br>
## Database migrations
We use [prisma](https://www.prisma.io/) for our database migrations. To create a new migration, modify `prisma/schema.prisma` according to [prisma schema referecne](https://www.prisma.io/docs/orm/reference/prisma-schema-reference) and apply it with:
`./sndev prisma migrate dev`
If you want to create a migration without applying it, eg to create a trigger or modify the generated sql before applying, use the `--create-only` option:
`./sndev prisma migrate dev --create-only`
Generate the local copy of the prisma ORM client in `node_modules` after changes. This should only be needed to get Intellisense in your editor locally.
`./sndev prisma generate`
<br>
## Connecting to the local database
You can connect to the local database via `./sndev psql`. [psql](https://www.postgresql.org/docs/13/app-psql.html) is an interactive terminal for working with PostgreSQL.
<br>
## Running lncli on the local lnd nodes
You can run `lndcli` on the local lnd nodes via `./sndev sn_lncli` and `./sndev stacker_lncli`. The node for your local SN instance is `sn_lnd` and the node serving as any external node, like a stacker's node or external wallet, is `stacker_lnd`.
<br>
## Testing local auth
You can login to test features like posting, replying, tipping, etc with `./sndev login <nym>` which will provide a link to login as an existing nym or a new account for a nonexistent nym. But, it you want to test auth specifically you'll need to configure them in your `.env` file.
### Login with Email
- Create a Sendgrid account (or other smtp service)
```
LOGIN_EMAIL_SERVER=smtp://apikey:<sendgrid_api_key>@smtp.sendgrid.net:587
LOGIN_EMAIL_FROM=<sendgrid_email_from>
```
- Click "sign up" and enter your email address
- Check your email
- Click the link (looks like this):
```
http://localhost:3000/api/auth/callback/email?email=satoshi%40gmail.com&token=110e30a954ce7ca643379d90eb511640733de405f34a31b38eeda8e254d48cd7
```
### Login with Github
- [Create a new OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) in your Github account
- Set the callback URL to: `http://localhost:3000/api/auth/callback/github`
- Update your `.env` file
```
GITHUB_ID=<Client ID>
GITHUB_SECRET=<Client secret>
```
- Signup and login as above
### Login with Lightning
- Use [ngrok](https://ngrok.com/) to create a HTTPS tunnel to localhost:3000
- Update `LNAUTH_URL` in `.env` with the URL provided by `ngrok` and add /api/lnauth to it
<br>
## Enabling web push notifications
To enable Web Push locally, you will need to set the `VAPID_*` env vars. `VAPID_MAILTO` needs to be an email address using the `mailto:` scheme. For `NEXT_PUBLIC_VAPID_KEY` and `VAPID_PRIVKEY`, you can run `npx web-push generate-vapid-keys`.
# imgproxy
<br>
To configure the image proxy, you will need to set the `IMGPROXY_` env vars. `NEXT_PUBLIC_IMGPROXY_URL` needs to point to the image proxy service. `IMGPROXY_KEY` and `IMGPROXY_SALT` can be set using `openssl rand -hex 64`.
# Internals
# stack
The site is written in javascript using Next.js, a React framework. The backend API is provided via GraphQL. The database is PostgreSQL modeled with Prisma. The job queue is also maintained in PostgreSQL. We use lnd for our lightning node. A customized Bootstrap theme is used for styling.
<br>
# processes
There are two. 1. the web app and 2. the worker, which dequeues jobs sent to it by the web app, e.g. processing images.
## Stack
# wallet transaction safety
To ensure stackers balances are kept sane, all wallet updates are run in serializable transactions at the database level. Because prisma has relatively poor support for transactions all wallet touching code is written in plpgsql stored procedures and can be found in the prisma/migrations folder.
The site is written in javascript (not typescript 😱) using [Next.js](https://nextjs.org/), a [React](https://react.dev/) framework. The backend API is provided via [GraphQL](https://graphql.org/). The database is [PostgreSQL](https://www.postgresql.org/) modeled with [Prisma](https://www.prisma.io/). The [job queue](https://github.com/timgit/pg-boss) is also maintained in PostgreSQL. We use [lnd](https://github.com/lightningnetwork/lnd) for our lightning node. A customized [Bootstrap](https://react-bootstrap.netlify.app/) theme is used for styling.
# code
The code is linted with standardjs.
<br>
# license
## Services
Currently, SN runs and maintains two significant services and one microservice:
1. the nextjs web app, found in `./`
2. the worker service, found in `./worker`, which runs period jobs and jobs sent to it by the web app
3. a screenshot microservice, found in `./capture`, which takes screenshots of SN for social previews
In addition, we run other critical services the above services interact with like `lnd`, `postgres`, `opensearch`, `tor`, and `s3`.
<br>
## Wallet transaction safety
To ensure stackers balances are kept sane, all wallet updates are run in [serializable transactions](https://www.postgresql.org/docs/current/transaction-iso.html#XACT-SERIALIZABLE) at the database level. Because early versions of prisma had relatively poor support for transactions most wallet touching code is written in [plpgsql](https://www.postgresql.org/docs/current/plpgsql.html) stored procedures and can be found in the `prisma/migrations` folder.
<br>
# Need help?
Open a [discussion](http://github.com/stackernews/stacker.news/discussions) or [issue](http://github.com/stackernews/stacker.news/issues/new) or [email us](mailto:kk@stacker.news) or [chat with us on telegram](https://t.me/stackernews).
<br>
# Responsible disclosure
If you found a vulnerability, we would greatly appreciate it if you contact us via [security@stacker.news](mailto:security@stacker.news) or open a [security advisory](https://github.com/stackernews/stacker.news/security/advisories/new).
<br>
# License
[MIT](https://choosealicense.com/licenses/mit/)

View File

@ -158,7 +158,12 @@ services:
sleep 1
done
echo "OpenSearch started."
curl -X PUT "http://localhost:9200/item" -ku admin:${OPENSEARCH_INITIAL_ADMIN_PASSWORD}
curl \
-H "Content-Type: application/json" \
-X PUT \
-d '{"mappings":{"properties":{"text":{"type":"text","analyzer":"english","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","analyzer":"english","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}' \
"http://localhost:9200/item" \
-ku admin:${OPENSEARCH_INITIAL_ADMIN_PASSWORD}
echo "OpenSearch index created."
fg
'

View File

@ -1,40 +0,0 @@
# Local Auth
You must be logged in to test features like posting, replying, tipping, etc.
### Login with Email
- First, follow the local development instructions in the README.md
- Create a Sendgrid account (or other smtp service)
- Update your `.env` file and source it in `docker-compose.yml`
```
LOGIN_EMAIL_SERVER=smtp://apikey:<sendgrid_api_key>@smtp.sendgrid.net:587
LOGIN_EMAIL_FROM=<sendgrid_email_from>
```
- Open http://localhost:3000
- Click "sign up" and enter your email address
- Check your email
- Click the link (looks like this):
```
http://localhost:3000/api/auth/callback/email?email=satoshi%40gmail.com&token=110e30a954ce7ca643379d90eb511640733de405f34a31b38eeda8e254d48cd7
```
### Login with Github
- [Create a new OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) in your Github account
- Set the callback URL to: `http://localhost:3000/api/auth/callback/github`
- Update your `.env` file
```
GITHUB_ID=<Client ID>
GITHUB_SECRET=<Client secret>
```
- Signup and login as above
### Login with Lightning
- Use [ngrok](https://ngrok.com/) to create a HTTPS tunnel to localhost:3000
- Update `LNAUTH_URL` in `.env` with the URL provided by `ngrok` and add /api/lnauth to it

View File

@ -1,177 +0,0 @@
# Local LND
To also work with wallet functionality, you need a local running LND node.
1. Download the AppImage for [polar](https://lightningpolar.com/) and run it.
2. Create a lightning network with one LND node and one Bitcoin Core node.
3. Start the network
4. Click on the LND node and make sure status is green
5. Go to "Connect" > "Hex"
6. Copy TLS cert and admin macaroon in hex into your env file
7. Create the network `stackernews_default` if it is not created yet. It is automatically created when running `docker-compose up`:
```
$ docker network create stackernews_default
Error response from daemon: network with name stackernews_default already exists
$ docker network inspect stackernews_default
[
{
"Name": "stackernews_default",
"Id": "2a5b089fb0f6f71f98c0f434f58cb368568227ced489c490d09cea3f63973a2a",
"Created": "2023-05-17T02:04:06.302835394+02:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.128.0/20",
"Gateway": "192.168.128.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "stackernews",
"com.docker.compose.version": "2.17.3"
}
}
]
```
8. Run `docker ps` and find the container name and GRPC container port of the LND node:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eb3480c0d0c4 polarlightning/lnd:0.16.0-beta "/entrypoint.sh lnd …" 8 minutes ago Up 8 minutes 0.0.0.0:9735->9735/tcp, :::9735->9735/tcp, 10000/tcp, 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp, 0.0.0.0:10001->10009/tcp, :::10001->10009/tcp polar-n1-alice
e0635bff36ba polarlightning/bitcoind:24.0 "/entrypoint.sh bitc…" 8 minutes ago Up 8 minutes 0.0.0.0:18443->18443/tcp, :::18443->18443/tcp, 0.0.0.0:28334->28334/tcp, :::28334->28334/tcp, 0.0.0.0:19444->18444/tcp, :::19444->18444/tcp, 0.0.0.0:29335->28335/tcp, :::29335->28335/tcp polar-n1-backend1
```
Here, it is `polar-n1-alice` and port is 10009 (**not 10001, that's the host port**).
9. Add the container to the network `stackernews_default`:
```
$ docker network connect stackernews_default polar-n1-alice
$ docker network inspect stackernews_default
[
{
"Name": "stackernews_default",
"Id": "2e1bc3297c95073dc3723051144587a8431f242d031fce2c27ec13be948783ec",
"Created": "2023-05-17T02:40:57.605076983+02:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.192.0/20",
"Gateway": "192.168.192.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"eb3480c0d0c4452cfe5cb94da6cb81a060d5a6db45526e15b960adbb01064930": {
"Name": "polar-n1-alice",
"EndpointID": "421462516a1d858f856ef5af0e677063b35777fe8b24134e129b82c889ef51d1",
"MacAddress": "02:42:c0:a8:c0:02",
"IPv4Address": "192.168.192.2/20",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
```
10. Set `LND_SOCKET` to `<container_name>:<grpc_container_port>`.
Make sure to use the container name as found in the output of `docker ps` or `docker network inspect`. **IPs do not work!**
11. Run `docker-compose up --build`
12. You should now see all four containers in the `stackernews_default` network:
```
$ docker network inspect stackernews_default
[
{
"Name": "stackernews_default",
"Id": "2e1bc3297c95073dc3723051144587a8431f242d031fce2c27ec13be948783ec",
"Created": "2023-05-17T02:40:57.605076983+02:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.192.0/20",
"Gateway": "192.168.192.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"97977685f6c3dfa74b37406a300a97dc188b32c248dd0f7d127804c4f5028d47": {
"Name": "db",
"EndpointID": "5c6307e5cf70108ac37965730180ae1ecadd39673c58146b0755fecea9964391",
"MacAddress": "02:42:c0:a8:c0:03",
"IPv4Address": "192.168.192.3/20",
"IPv6Address": ""
},
"b8b48fd9c6464d70e4ab0140102be233ade57d3898a00572eb261469b3a510f8": {
"Name": "worker",
"EndpointID": "cdb488fec12b127e502326bbfafbde4704ed26faf70a9ca76db9ae8fa480a487",
"MacAddress": "02:42:c0:a8:c0:05",
"IPv4Address": "192.168.192.5/20",
"IPv6Address": ""
},
"eb3480c0d0c4452cfe5cb94da6cb81a060d5a6db45526e15b960adbb01064930": {
"Name": "polar-n1-alice",
"EndpointID": "421462516a1d858f856ef5af0e677063b35777fe8b24134e129b82c889ef51d1",
"MacAddress": "02:42:c0:a8:c0:02",
"IPv4Address": "192.168.192.2/20",
"IPv6Address": ""
},
"fe8be23961026e0fc264e384e8f3715956cb0b947d6b9925f71f1071dc07c402": {
"Name": "app",
"EndpointID": "660c360c4750a69c1f77eb40c510b3cc679bb1ae4442f648d41c40402abb5f85",
"MacAddress": "02:42:c0:a8:c0:04",
"IPv4Address": "192.168.192.4/20",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
```
13. Watch logs of app container for "LND GRPC connection error" or "LND GRPC connection successful"

View File

@ -1,27 +0,0 @@
# Testing Search
You may want to create an index that more closely resembles prod for testing search. The simplest way is to create an index that applies an english analyzer on `title` and `text` fields.
### Create a new index in OpenSearch
```bash
curl
\ -H "Content-Type: application/json"
\ -X PUT
\ -d '{"mappings":{"properties":{"text":{"type":"text","analyzer":"english","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","analyzer":"english","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}'
\ "http://localhost:9200/english"
\ -ku admin:admin
```
### Reindex your documents into the `english` index
```bash
curl
\ -H "Content-Type: application/json"
\ -X POST
\ -d '{"source":{"index":"item"},"dest":{"index":"english"}}'
\ "http://localhost:9200/_reindex?wait_for_completion=false"
\ -ku admin:admin
```
### Update `.env.sample`
Search for `OPENSEARCH_INDEX=item` and replace it with `OPENSEARCH_INDEX=english`

19
sndev
View File

@ -248,6 +248,22 @@ COMMANDS"
sndev__prisma --help | awk '/Commands/{y=1;next}y' | awk '!/^([\t ]+init)|([\t ]+studio)/' | sed -n '/Flags/q;p'
}
sndev__lint() {
shift
docker__exec -t -u apprunner app npm run lint
}
sndev__help_lint() {
help="
run linters
USAGE
$ sndev lint
"
echo "$help"
}
sndev__compose() {
shift
docker__compose "$@"
@ -372,8 +388,9 @@ COMMANDS
psql open psql on db
prisma run prisma commands
github:
dev:
pr fetch and checkout a pr
lint run linters
other:
compose docker compose passthrough