From 513cac22d3eccf4e8dbc4983f43dccb0c5422d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Fernandes?= Date: Mon, 24 Feb 2025 11:54:48 -0300 Subject: [PATCH] update docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: DiĆ³genes Fernandes --- Makefile | 8 +++++++- search/worker/README.md | 30 +++++++----------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index e8c3460..3c12b57 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # generate-registry runs `go generate` to build the registry files and saves them to /tmp/registry generate-registry: - @cd "$(CURDIR)/backend" && go run ./cmd/generate/ --licenses-file ../licenses.json --destination-dir /tmp/registry + @cd "$(CURDIR)/backend" && go generate ./... && go run ./cmd/generate/ --licenses-file ../licenses.json --destination-dir /tmp/registry # load-registry feed the data from /tmp/registry into the local R2 bucket (search/worker/.wrangler/state/r2) folder load-registry: @@ -9,3 +9,9 @@ load-registry: # index-search downloads search data from api.opentofu.org and feeds that data into the postgres database used for searching index-search: @cd "$(CURDIR)/search/pg-indexer" && PG_CONNECTION_STRING=postgres://postgres:secret@localhost:5432/postgres?sslmode=disable go run . + +# after docker-compose us running, run this command to feed data into the application +feed-data: + make generate-registry + make load-registry + make index-search diff --git a/search/worker/README.md b/search/worker/README.md index d33e84b..b58040a 100644 --- a/search/worker/README.md +++ b/search/worker/README.md @@ -1,30 +1,14 @@ # Search worker -To setup your local environment for this project: - -1. Copy the `.example.dev.vars` to a new `.dev.vars` file in the same folder. -2. Postgres Search data: - -- Go to `search/pg-indexer` folder and run `PG_CONNECTION_STRING=postgres://postgres:secret@localhost:5432/postgres?sslmode=disable go run . ` to populate the postgres search. - -3. R2 data from providers: +The Search worker is used as the backend that route requests on our Cloudflare Worker. Static files are served from R2 directly and search goes to our serverless Neon Database. There's a cache in Cloudflare worker as well that is handled by this application. -Go to the `backend` folder and run: +## Installation -``` -go run ./cmd/generate/ --licenses-file ../licenses.json --tofu-binary-path=$(which tofu) --destination-dir /tmp/registry --namespace -``` - -to generate for a namespace and for a full load use: - -``` -go run ./cmd/generate/ --licenses-file ../licenses.json --tofu-binary-path=$(which tofu)$ --destination-dir /tmp/registry -``` +To setup your local environment for this project: -This will create a folder in /tmp/registry with all the registry data. +1. Copy the `.example.dev.vars` to a new `.dev.vars` file in the same folder. +2. When running docker-compose, the whole folder will be copied, so you can overwrite `.dev.vars` with your environment variables. -To load these files into our R2 local bucket, use the script: +## Feeding data -``` -cd search/worker && npm run feed-data -``` +There's a `Makefile` folder on the root with commands to setup the data in this application.