Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add `catalog/init` just command (#2915)

Krystle Salazar4c6c41c97ff9
diff --git a/catalog/justfile b/catalog/justfile
index 9689c2267..8d9f0c333 100644
--- a/catalog/justfile
+++ b/catalog/justfile
@@ -63,10 +63,15 @@ up *flags:
up-deps *flags:
env COMPOSE_PROFILES="catalog_dependencies" just ../up {{ flags }}
+# Load sample data into upstream DB
+init: up
+ cd .. && ./load_sample_data.sh -c
+
# Tear down all the services and recreate the ones of the catalog profile
recreate:
just ../down -v
just up --force-recreate --build
+ just init
##################
# Administration #
diff --git a/justfile b/justfile
index 36b6eb7e1..7d74a8f4c 100644
--- a/justfile
+++ b/justfile
@@ -170,7 +170,6 @@ wait-up: up
just ingestion_server/wait-up
just api/wait-up
just frontend/wait-up
- just catalog/wait-up
# Also see `init` recipe in sub-justfiles
# Load sample data into the Docker Compose services
diff --git a/load_sample_data.sh b/load_sample_data.sh
index bc55042ae..344b3f33a 100755
--- a/load_sample_data.sh
+++ b/load_sample_data.sh
@@ -5,6 +5,18 @@ CACHE_SERVICE_NAME="${CACHE_SERVICE_NAME:-cache}"
UPSTREAM_DB_SERVICE_NAME="${UPSTREAM_DB_SERVICE_NAME:-upstream_db}"
DB_SERVICE_NAME="${DB_SERVICE_NAME:-db}"
+while getopts 'c' OPTION; do
+ case "$OPTION" in
+ c)
+ echo "Loading upstream DB data..."
+ upstream_only=true
+ ;;
+ ?)
+ echo "Loading all sample data..."
+ ;;
+ esac
+done
+
###############
# Upstream DB #
###############
@@ -35,6 +47,11 @@ verify_loaded_data "image"
load_sample_data "audio"
verify_loaded_data "audio"
+# Terminate the script if received flag for only upstream data
+if [ "$upstream_only" = true ]; then
+ exit 0
+fi
+
#######
# API #
#######