Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Diógenes Fernandes <[email protected]>
  • Loading branch information
diofeher committed Feb 24, 2025
1 parent 18b46bf commit 513cac2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
30 changes: 7 additions & 23 deletions search/worker/README.md
Original file line number Diff line number Diff line change
@@ -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 <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.

0 comments on commit 513cac2

Please sign in to comment.