Add OpenSearch to docker setup for development (#509)
* add containers for OpenSearch * switch OpenSearch Dashboards to http * add script to take care of index/mapping on first run * limit mount in opensearch container to only the necessary scope * handle both docker and non-docker dev setups * cleanup * make opensearch work in docker dev --------- Co-authored-by: rleed <rleed1@pm.me> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
This commit is contained in:
		
							parent
							
								
									8017355924
								
							
						
					
					
						commit
						2a7267a35a
					
				@ -57,13 +57,18 @@ NOSTR_PRIVATE_KEY=<YOUR NOSTR PRIVATE KEY IN HEX>
 | 
			
		||||
 | 
			
		||||
# static things
 | 
			
		||||
NEXTAUTH_URL=http://localhost:3000/api/auth
 | 
			
		||||
SELF_URL=http://localhost:3000
 | 
			
		||||
SELF_URL=http://app:3000
 | 
			
		||||
PUBLIC_URL=http://localhost:3000
 | 
			
		||||
LND_CONNECT_ADDRESS=03cc1d0932bb99b0697f5b5e5961b83ab7fd66f1efc4c9f5c7bad66c1bcbe78f02@xhlmkj7mfrl6ejnczfwl2vqik3xim6wzmurc2vlyfoqw2sasaocgpuad.onion:9735
 | 
			
		||||
NEXTAUTH_SECRET=3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI
 | 
			
		||||
JWT_SIGNING_PRIVATE_KEY={"kty":"oct","kid":"FvD__hmeKoKHu2fKjUrWbRKfhjimIM4IKshyrJG4KSM","alg":"HS512","k":"3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI"}
 | 
			
		||||
INVOICE_HMAC_KEY=a4c1d9c81edb87b79d28809876a18cf72293eadb39f92f3f4f2f1cfbdf907c91
 | 
			
		||||
 | 
			
		||||
# OpenSearch
 | 
			
		||||
OPENSEARCH_URL=http://opensearch:9200
 | 
			
		||||
OPENSEARCH_USERNAME=
 | 
			
		||||
OPENSEARCH_PASSWORD=
 | 
			
		||||
 | 
			
		||||
# imgproxy options
 | 
			
		||||
IMGPROXY_ENABLE_WEBP_DETECTION=1
 | 
			
		||||
IMGPROXY_MAX_ANIMATION_FRAMES=100
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import os from '@opensearch-project/opensearch'
 | 
			
		||||
 | 
			
		||||
const options = process.env.NODE_ENV === 'development'
 | 
			
		||||
  ? { node: 'http://localhost:9200' }
 | 
			
		||||
  ? { node: process.env.OPENSEARCH_URL || 'http://localhost:9200' }
 | 
			
		||||
  : {
 | 
			
		||||
      node: process.env.OPENSEARCH_URL,
 | 
			
		||||
      auth: {
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,7 @@ services:
 | 
			
		||||
      - ./:/app
 | 
			
		||||
    links:
 | 
			
		||||
      - db
 | 
			
		||||
      - opensearch
 | 
			
		||||
  worker:
 | 
			
		||||
    container_name: worker
 | 
			
		||||
    build: ./worker
 | 
			
		||||
@ -47,6 +48,8 @@ services:
 | 
			
		||||
      - ./:/app
 | 
			
		||||
    links:
 | 
			
		||||
      - db
 | 
			
		||||
      - app
 | 
			
		||||
      - opensearch
 | 
			
		||||
    entrypoint: ["/bin/sh", "-c"]
 | 
			
		||||
    command:
 | 
			
		||||
      - node worker/index.js
 | 
			
		||||
@ -67,5 +70,46 @@ services:
 | 
			
		||||
      - "3001:8080"
 | 
			
		||||
    links:
 | 
			
		||||
      - app
 | 
			
		||||
  opensearch:
 | 
			
		||||
    image: opensearchproject/opensearch:latest
 | 
			
		||||
    container_name: opensearch
 | 
			
		||||
    environment:
 | 
			
		||||
      - discovery.type=single-node
 | 
			
		||||
      - plugins.security.disabled=true
 | 
			
		||||
    ports:
 | 
			
		||||
      - 9200:9200 # REST API
 | 
			
		||||
      - 9600:9600 # Performance Analyzer
 | 
			
		||||
    volumes:
 | 
			
		||||
      - os:/usr/share/opensearch/data
 | 
			
		||||
      - ./:/app
 | 
			
		||||
    command: >
 | 
			
		||||
      bash -c '
 | 
			
		||||
        set -m
 | 
			
		||||
        /usr/share/opensearch/opensearch-docker-entrypoint.sh &
 | 
			
		||||
        until curl -sS "http://localhost:9200/_cat/health?h=status" -ku admin:admin | grep -q "green\|yellow"; do
 | 
			
		||||
          echo "Waiting for OpenSearch to start..."
 | 
			
		||||
          sleep 1
 | 
			
		||||
        done
 | 
			
		||||
        echo "OpenSearch started."
 | 
			
		||||
        curl -X PUT "http://localhost:9200/item" -ku admin:admin
 | 
			
		||||
        echo "OpenSearch index created."
 | 
			
		||||
        fg
 | 
			
		||||
      '
 | 
			
		||||
  os-dashboard:
 | 
			
		||||
    image: opensearchproject/opensearch-dashboards:latest
 | 
			
		||||
    container_name: os-dashboard
 | 
			
		||||
    environment:
 | 
			
		||||
      - opensearch.ssl.verificationMode=none
 | 
			
		||||
      - server.ssl.enabled=false
 | 
			
		||||
      - plugins.security.disabled=true
 | 
			
		||||
      - DISABLE_SECURITY_DASHBOARDS_PLUGIN=true
 | 
			
		||||
      - OPENSEARCH_HOSTS=http://opensearch:9200
 | 
			
		||||
    ports:
 | 
			
		||||
      - 5601:5601
 | 
			
		||||
    expose:
 | 
			
		||||
      - "5601"
 | 
			
		||||
    links:
 | 
			
		||||
      - opensearch
 | 
			
		||||
volumes:
 | 
			
		||||
  db:
 | 
			
		||||
  os:
 | 
			
		||||
 | 
			
		||||
@ -77,6 +77,7 @@ async function _indexItem (item) {
 | 
			
		||||
 | 
			
		||||
export function indexItem ({ apollo }) {
 | 
			
		||||
  return async function ({ data: { id } }) {
 | 
			
		||||
    console.log('indexing item, fetching ...', id)
 | 
			
		||||
    // 1. grab item from database
 | 
			
		||||
    // could use apollo to avoid duping logic
 | 
			
		||||
    // when grabbing sats and user name, etc
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user