Skip to content

Commit

Permalink
Hardcode discovery engine env vars
Browse files Browse the repository at this point in the history
We've decided it's easier for the local setup of search-api-v2 to pull
in search results from integration whenever search results are needed
for local testing rather than making everyone set up their own personal
discovery engine on gcloud. Therefore the env var values can be
hardcoded rather than being set in the local session.
  • Loading branch information
leenagupte committed Jan 5, 2024
1 parent efe2664 commit 9f46ef2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
14 changes: 0 additions & 14 deletions projects/search-api-v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,5 @@ define SEARCH_API_V2_WARN_GCLOUD
These are mounted into the container. See the README for details.\033[0m
endef

define SEARCH_API_V2_WARN_DATASTORE_BRANCH
\033[1;31mWarning: DISCOVERY_ENGINE_DATASTORE_BRANCH environment variable is not set.\
\n\033[0;31mYou need to set this environment variable locally before running govuk-docker up,\
otherwise the app will not be able to access Discovery Engine. See the README for details.\033[0m
endef

define SEARCH_API_V2_WARN_SERVING_CONFIG
\033[1;31mWarning: DISCOVERY_ENGINE_SERVING_CONFIG environment variable is not set.\
\n\033[0;31mYou need to set this environment variable locally before running govuk-docker up,\
otherwise the app will not be able to access Discovery Engine. See the README for details.\033[0m
endef

prerequisites-search-api-v2:
@command -v gcloud >/dev/null 2>&1 || { echo "$(SEARCH_API_V2_WARN_GCLOUD)"; }
@[ -n "$${DISCOVERY_ENGINE_DATASTORE_BRANCH}" ] || { echo "$(SEARCH_API_V2_WARN_DATASTORE_BRANCH)"; }
@[ -n "$${DISCOVERY_ENGINE_SERVING_CONFIG}" ] || { echo "$(SEARCH_API_V2_WARN_SERVING_CONFIG)"; }
24 changes: 7 additions & 17 deletions projects/search-api-v2/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ services:
RAILS_DEVELOPMENT_HOSTS: "search-api-v2.dev.gov.uk,search-api-v2-app"
VIRTUAL_HOST: "search-api-v2.dev.gov.uk"
BINDING: "0.0.0.0"
# The fully qualified ID of the datastore branch and engine on the Discovery Engine dev
# environment (required to use Discovery Engine locally, can be set on `govuk-docker up`
# invocation or permanently in your local environment).
# The fully qualified ID of the datastore branch and engine on the Discovery Engine integration
# environment (required to use Discovery Engine locally).
#
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/
# local-my-name/branches/default_branch"
DISCOVERY_ENGINE_DATASTORE_BRANCH: "${DISCOVERY_ENGINE_DATASTORE_BRANCH}"
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/
# local-my-name/servingConfigs/default_serving_config"
DISCOVERY_ENGINE_SERVING_CONFIG: "${DISCOVERY_ENGINE_SERVING_CONFIG}"
DISCOVERY_ENGINE_DATASTORE_BRANCH: "projects/search-api-v2-integration/locations/global/collections/default_collection/dataStores/govuk_content/branches/default_branch"
DISCOVERY_ENGINE_SERVING_CONFIG: "projects/search-api-v2-integration/locations/global/collections/default_collection/dataStores/govuk_content/servingConfigs/default_search"
expose:
- "3000"
command: bin/rails server --restart
Expand All @@ -62,13 +57,8 @@ services:
RABBITMQ_URL: "amqp://guest:guest@rabbitmq"
PUBLISHED_DOCUMENTS_MESSAGE_QUEUE_NAME: "search_api_v2_published_documents"
# The fully qualified ID of the datastore branch and serving config on the Discovery Engine
# dev environment (required to use Discovery Engine locally, can be set on `govuk-docker up`
# invocation or permanently in your local environment).
# integration environment (required to use Discovery Engine locally).
#
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/
# local-my-name/branches/default_branch"
DISCOVERY_ENGINE_DATASTORE_BRANCH: "${DISCOVERY_ENGINE_DATASTORE_BRANCH}"
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/
# local-my-name/servingConfigs/default_serving_config"
DISCOVERY_ENGINE_SERVING_CONFIG: "${DISCOVERY_ENGINE_SERVING_CONFIG}"
DISCOVERY_ENGINE_DATASTORE_BRANCH: "projects/search-api-v2-integration/locations/global/collections/default_collection/dataStores/govuk_content/branches/default_branch"
DISCOVERY_ENGINE_SERVING_CONFIG: "projects/search-api-v2-integration/locations/global/collections/default_collection/dataStores/govuk_content/servingConfigs/default_search"
command: bin/rake document_sync_worker:run

0 comments on commit 9f46ef2

Please sign in to comment.