mirror of
https://github.com/edufeed-org/typesense-indexer.git
synced 2025-12-07 23:34:35 +00:00
Get it running with docker
This commit is contained in:
parent
b763c11d37
commit
70700843ae
8 changed files with 32 additions and 17 deletions
3
.env.example
Normal file
3
.env.example
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
RELAY_URL=wss://my-relay.org
|
||||
TS_URL=https://my-typsense.org
|
||||
TS_KEY=abc
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -28,3 +28,4 @@
|
|||
/classes
|
||||
/target
|
||||
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
|||
RUN clojure -T:build uber
|
||||
|
||||
# Stage 2: Run the Uberjar in a minimal image
|
||||
FROM openjdk:17-jdk-slim
|
||||
FROM openjdk:23-jdk-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV APP_HOME=/usr/src/app
|
||||
|
|
|
|||
16
deps.edn
16
deps.edn
|
|
@ -1,11 +1,11 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
|
||||
org.clojure/core.async {:mvn/version "1.6.673"}
|
||||
com.stuartsierra/component {:mvn/version "1.1.0"}
|
||||
hato/hato {:mvn/version "1.0.0"}
|
||||
http-kit/http-kit {:mvn/version "2.8.0"}
|
||||
net.clojars.laoc/nostr {:local/root "/home/laoc/coding/nostr-clj"}
|
||||
aero/aero {:mvn/version "1.1.6"}
|
||||
cheshire/cheshire {:mvn/version "5.10.0"}}
|
||||
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
|
||||
org.clojure/core.async {:mvn/version "1.6.673"}
|
||||
com.stuartsierra/component {:mvn/version "1.1.0"}
|
||||
hato/hato {:mvn/version "1.0.0"}
|
||||
http-kit/http-kit {:mvn/version "2.9.0-alpha2"}
|
||||
net.clojars.laoc/nostr {:mvn/version "0.0.7"}
|
||||
aero/aero {:mvn/version "1.1.6"}
|
||||
cheshire/cheshire {:mvn/version "5.10.0"}}
|
||||
:aliases {:build {:extra-deps {io.github.clojure/tools.build {:mvn/version "0.9.3"}}
|
||||
:ns-default build}}}
|
||||
|
|
|
|||
10
docker-compose.yaml
Normal file
10
docker-compose.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
services:
|
||||
indexer:
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
RELAY_URL: "${RELAY_URL}"
|
||||
TS_URL: "${TS_URL}"
|
||||
TS_KEY: "${TS_KEY}"
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
{:websocket {:url "ws://localhost:7778"}
|
||||
:typesense {:url "http://localhost:8108"
|
||||
:api-key "xyz"}}
|
||||
{:websocket {:url #or [#env RELAY_URL "wss://my-relay.org"]}
|
||||
:typesense {:url #or [#env TS_URL "https://my-typesense.org"]
|
||||
:api-key #or [#env TS_KEY "abc"]}}
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@
|
|||
(case reason
|
||||
"eose" (do
|
||||
(nostr/unsubscribe ws {:kinds [30142]
|
||||
:limit 6})
|
||||
:limit 10000})
|
||||
(nostr/subscribe ws {:kinds [30142]
|
||||
:since (:created_at @newest-event)}))
|
||||
"reconnect" (nostr/subscribe ws {:kinds [1]
|
||||
:limit 4
|
||||
:limit 10000
|
||||
:until (:created_at @last-event)})
|
||||
"init" (nostr/subscribe ws {:kinds [30142]
|
||||
:limit 6})))
|
||||
:limit 10000})))
|
||||
|
||||
(defn on-message-handler [ws parsed last-parsed-event newest-event typesense]
|
||||
(try
|
||||
|
|
@ -41,11 +41,11 @@
|
|||
component/Lifecycle
|
||||
(start [component]
|
||||
(println ";; Starting WebsocketConnection")
|
||||
(println ";; typesense" typesense)
|
||||
(println ";; Websocket config" config)
|
||||
(let [last-parsed-event (atom {:created_at nil})
|
||||
newest-event (atom nil)]
|
||||
(try
|
||||
(let [{:keys [ws channel]} (nostr/connect-channel (:url config))]
|
||||
(let [{:keys [ws channel]} (nostr/connect (:url config))]
|
||||
(init-request-30142 ws last-parsed-event newest-event "init")
|
||||
(go-loop []
|
||||
(when-some [message (<! channel)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
(ns typesense-indexer.system
|
||||
(:gen-class)
|
||||
(:require [com.stuartsierra.component :as component]
|
||||
[typesense-indexer.config :as config]
|
||||
[typesense-indexer.components.websocket :as ws]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue