wip docker-compose setup

This commit is contained in:
Steve Perkins 2023-02-13 20:44:06 -05:00
parent 05600231b4
commit 0e18a49861
5 changed files with 33 additions and 26 deletions

2
go.mod
View File

@ -83,4 +83,4 @@ require (
golang.org/x/text v0.3.7 // indirect
)
replace github.com/nbd-wtf/go-nostr => /Users/steve/opc/go-nostr
replace github.com/nbd-wtf/go-nostr => ../go-nostr

1
go.sum
View File

@ -371,6 +371,7 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stereosteve/go-nostr v0.13.1/go.mod h1:qFFTIxh15H5GGN0WsBI/P73DteqsevnhSEW/yk8nEf4=
github.com/stevelacy/daz v0.1.4 h1:ugmff/D7D764wZjXSgSryEINE/bi+Xddllw3JQQGbWk=
github.com/stevelacy/daz v0.1.4/go.mod h1:AbK6DzjiIL15r4bQtcFvOBAvDGMXoh+uIG26NRUugt0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

View File

@ -1,20 +1,23 @@
version: "3.8"
services:
# relay:
# build:
# context: ../
# dockerfile: ./basic/Dockerfile
# environment:
# PORT: 2700
# POSTGRESQL_DATABASE: postgres://nostr:nostr@postgres:5432/nostr?sslmode=disable
# depends_on:
# postgres:
# condition: service_healthy
# ports:
# - 2700:2700
# command: "./basic/relayer-basic"
relay:
image: golang
# build:
# context: ../
# dockerfile: ./basic/Dockerfile
environment:
PORT: 2700
ES_URL: http://elasticsearch:9200
depends_on:
elasticsearch:
condition: service_healthy
ports:
- 2700:2700
volumes:
- ./nostres:/bin/relay
command: "/bin/relay"
elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.6.0
@ -39,5 +42,3 @@ services:
interval: 10s
timeout: 5s
retries: 5

View File

@ -15,7 +15,7 @@ type Relay struct {
}
func (r *Relay) Name() string {
return "BasicRelay"
return "SearchRelay"
}
func (r *Relay) Storage() relayer.Storage {

View File

@ -7,6 +7,7 @@ import (
"fmt"
"io"
"log"
"os"
"strings"
"time"
@ -52,19 +53,18 @@ type ElasticsearchStorage struct {
}
func (ess *ElasticsearchStorage) Init() error {
es, err := elasticsearch.NewDefaultClient()
cfg := elasticsearch.Config{}
if x := os.Getenv("ES_URL"); x != "" {
cfg.Addresses = strings.Split(x, ",")
}
es, err := elasticsearch.NewClient(cfg)
if err != nil {
return err
}
// log.Println(elasticsearch.Version)
// log.Println(es.Info())
// todo: config
// todo: config + mapping settings
ess.indexName = "test3"
// todo: don't delete index every time
// es.Indices.Delete([]string{ess.indexName})
res, err := es.Indices.Create(ess.indexName, es.Indices.Create.WithBody(strings.NewReader(indexMapping)))
if err != nil {
return err
@ -139,7 +139,12 @@ func (ess *ElasticsearchStorage) SaveEvent(event *nostr.Event) error {
}
// post processing: index for FTS
// this could also possibly do custom indexing for kind=0.
// some ideas:
// - index kind=0 fields a set of dedicated mapped fields
// (or use a separate index for profiles with a dedicated mapping)
// - if it's valid JSON just index the "values" and not the keys
// - more content introspection: language detection
// - denormalization... attach profile + ranking signals to events
if event.Kind != 4 {
ie.ContentSearch = event.Content
}