Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
[Issue #191] Cleanup makefile commands around OpenSearch (#192)
Browse files Browse the repository at this point in the history
## Summary
Fixes #191

### Time to review: __5 mins__

## Changes proposed
Adjusted a few makefile commands / added some additional docs

Renamed `db-recreate` to `volume-recreate` as the command also recreates
the OpenSearch volume.

Added a command for populating your OpenSearch index locally for
opportunities rather than needing to build the full command yourself.

## Context for reviewers
As we've added more commands to the Makefile, we haven't kept ontop of
how they all interact. This should add some level of clarity to the
commands.

The new `make populate-search-opportunities` command is a much easier
way of writing out the full command of `docker compose run --rm
grants-api poetry run flask load-search-data load-opportunity-data`.

## Additional information
Note that we have a `make help` command which prints out any command
with a `## help text` on the target definition in the makefile:
<img width="1353" alt="Screenshot 2024-09-06 at 4 38 02 PM"
src="https://github.com/user-attachments/assets/d21f25c4-031f-4028-bf6b-d73908215b01">
  • Loading branch information
chouinar committed Sep 9, 2024
1 parent 7fd6e25 commit 0f175b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,22 @@ setup-local:
build:
docker compose build

start:
start: ## Start the API
docker compose up --detach

start-debug:
docker compose -f docker-compose.yml -f docker-compose.debug.yml up --detach

run-logs: start
run-logs: start ## Start the API and follow the logs
docker compose logs --follow --no-color $(APP_NAME)

init: build init-db init-opensearch init-localstack

clean-volumes: ## Remove project docker volumes (which includes the DB state)
clean-volumes: ## Remove project docker volumes - which includes the DB, and OpenSearch state
docker compose down --volumes

volume-recreate: clean-volumes init ## Destroy current volumes, setup new ones - will remove all existing data

stop:
docker compose down

Expand All @@ -126,9 +128,6 @@ start-db:
docker compose up --detach grants-db
./bin/wait-for-local-db.sh

## Destroy current DB, setup new one
db-recreate: clean-volumes init-db

#########################
# DB Migrations
#########################
Expand Down Expand Up @@ -166,7 +165,7 @@ db-migrate-history: ## Show migration history
db-migrate-heads: ## Show migrations marked as a head
$(alembic_cmd) heads $(args)

db-seed-local:
db-seed-local: ## Generate records into your local database
$(PY_RUN_CMD) db-seed-local $(args)

db-check-migrations: ## Verify the DB schema matches the DB migrations generated
Expand All @@ -183,8 +182,7 @@ setup-postgres-db: ## Does any initial setup necessary for our local database to
# Opensearch
##################################################

init-opensearch: start-opensearch
# TODO - in subsequent PRs, we'll add more to this command to setup the search index locally
init-opensearch: start-opensearch ## Start the opensearch service locally

start-opensearch:
docker compose up --detach opensearch-node
Expand Down Expand Up @@ -275,6 +273,9 @@ setup-foreign-tables:
seed-local-legacy-tables:
$(PY_RUN_CMD) python3 -m tests.lib.seed_local_legacy_tables

populate-search-opportunities: ## Load opportunities from the DB into the search index, run "make db-seed-local" first to populate your database
$(FLASK_CMD) load-search-data load-opportunity-data $(args)

##################################################
# Miscellaneous Utilities
##################################################
Expand Down
2 changes: 1 addition & 1 deletion documentation/api/database/database-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This command is not needed when starting the application with `make start`
To clean the database, use the following command:

```sh
make db-recreate
make volume-recreate
```

This will remove _all_ docker project volumes, rebuild the database volume, and
Expand Down

0 comments on commit 0f175b1

Please sign in to comment.