Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up Google environment for search-api-v2 #695

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion projects/search-api-v2/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
search-api-v2: bundle-search-api-v2
search-api-v2: prerequisites-search-api-v2 bundle-search-api-v2
$(GOVUK_DOCKER) run $@-lite bundle exec rake document_sync_worker:create_queue

BOLD_RED=\033[1;31m
REG_RED=\033[0;31m
RESET=\033[0m

define SEARCH_API_V2_WARN_GCLOUD
\033[1;31mWarning: gcloud not found on PATH.\n\
\033[0;31msearch-api-v2 requires credentials from the gcloud CLI to access Google Cloud Platform. \
These are mounted into the container. See the README for details.\033[0m
endef

define SEARCH_API_V2_WARN_DATASTORE
\033[1;31mWarning: DISCOVERY_ENGINE_DATASTORE 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}" ] || { echo "$(SEARCH_API_V2_WARN_DATASTORE)"; }
27 changes: 20 additions & 7 deletions projects/search-api-v2/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ x-search-api-v2: &search-api-v2
- ${GOVUK_ROOT_DIR:-~/govuk}:/govuk:delegated
- search-api-v2-tmp:/govuk/search-api-v2/tmp
- root-home:/root
# Mount the host's gcloud config directory into the container so that the app can use
# Application Default Credentials (required to use Discovery Engine locally)
- "~/.config/gcloud:/root/.config/gcloud:delegated"
working_dir: /govuk/search-api-v2

volumes:
Expand All @@ -30,11 +33,16 @@ services:
- rabbitmq
- search-api-v2-document-sync-worker
environment:
RABBITMQ_URL: amqp://guest:guest@rabbitmq
PUBLISHED_DOCUMENTS_MESSAGE_QUEUE_NAME: search_api_v2_published_documents
RAILS_DEVELOPMENT_HOSTS: search-api-v2.dev.gov.uk
VIRTUAL_HOST: search-api-v2.dev.gov.uk
BINDING: 0.0.0.0
RABBITMQ_URL: "amqp://guest:guest@rabbitmq"
PUBLISHED_DOCUMENTS_MESSAGE_QUEUE_NAME: "search_api_v2_published_documents"
RAILS_DEVELOPMENT_HOSTS: "search-api-v2.dev.gov.uk"
VIRTUAL_HOST: "search-api-v2.dev.gov.uk"
BINDING: "0.0.0.0"
# The fully qualified ID of the datastore on Discovery Engine (required to use Discovery
# Engine locally, can be set on `govuk-docker up` invocation or permanently in your local
# environment)
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/local-my-name"
DISCOVERY_ENGINE_DATASTORE: "${DISCOVERY_ENGINE_DATASTORE}"
expose:
- "3000"
command: bin/rails server --restart
Expand All @@ -44,6 +52,11 @@ services:
depends_on:
- rabbitmq
environment:
RABBITMQ_URL: amqp://guest:guest@rabbitmq
PUBLISHED_DOCUMENTS_MESSAGE_QUEUE_NAME: search_api_v2_published_documents
RABBITMQ_URL: "amqp://guest:guest@rabbitmq"
PUBLISHED_DOCUMENTS_MESSAGE_QUEUE_NAME: "search_api_v2_published_documents"
# The fully qualified ID of the datastore on Discovery Engine (required to use Discovery
# Engine locally, can be set on `govuk-docker up` invocation or permanently in your local
# environment)
# e.g. "projects/search-api-v2-dev/locations/global/collections/default_collection/dataStores/local-my-name"
DISCOVERY_ENGINE_DATASTORE: "${DISCOVERY_ENGINE_DATASTORE}"
command: bin/rake document_sync_worker:run
2 changes: 1 addition & 1 deletion spec/integration/make/dependencies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

it "has only valid dependencies in the #{project_name} Makefile" do
app_dependencies = MakefileHelper.dependencies(project_name)
.reject { |dep| dep =~ /^(bundle|clone)/ }
.reject { |dep| dep =~ /^(bundle|clone|prerequisites)/ }

expect((app_dependencies - ProjectsHelper.all_projects)).to eq([])
end
Expand Down