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

Commit

Permalink
Merge branch 'main' into rylew/40-pa11y-ci-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rylew1 authored Jun 4, 2024
2 parents ecaec30 + 9574e29 commit 0d03cb4
Show file tree
Hide file tree
Showing 167 changed files with 3,823 additions and 2,420 deletions.
15 changes: 14 additions & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ start-debug:
run-logs: start
docker-compose logs --follow --no-color $(APP_NAME)

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

clean-volumes: ## Remove project docker volumes (which includes the DB state)
docker-compose down --volumes
Expand Down Expand Up @@ -179,6 +179,19 @@ create-erds: # Create ERD diagrams for our DB schema
setup-postgres-db: ## Does any initial setup necessary for our local database to work
$(PY_RUN_CMD) setup-postgres-db

##################################################
# Opensearch
##################################################

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

start-opensearch:
docker-compose up --detach opensearch-node
docker-compose up --detach opensearch-dashboards
./bin/wait-for-local-opensearch.sh



##################################################
# Testing
Expand Down
31 changes: 31 additions & 0 deletions api/bin/wait-for-local-opensearch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# wait-for-local-opensearch

set -e

# Color formatting
RED='\033[0;31m'
NO_COLOR='\033[0m'

MAX_WAIT_TIME=30 # seconds
WAIT_TIME=0

# Curl the healthcheck endpoint of the local opensearch
# until it returns a success response
until curl --output /dev/null --silent http://localhost:9200/_cluster/health;
do
echo "waiting on OpenSearch to initialize..."
sleep 3

WAIT_TIME=$(($WAIT_TIME+3))
if [ $WAIT_TIME -gt $MAX_WAIT_TIME ]
then
echo -e "${RED}ERROR: OpenSearch appears to not be starting up, running \"docker logs opensearch-node\" to troubleshoot.${NO_COLOR}"
docker logs opensearch-node
exit 1
fi
done

echo "OpenSearch is ready after ~${WAIT_TIME} seconds"


37 changes: 37 additions & 0 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,41 @@ services:
volumes:
- grantsdbdata:/var/lib/postgresql/data

opensearch-node:
image: opensearchproject/opensearch:latest
container_name: opensearch-node
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node # Name the node that will run in this container
- discovery.type=single-node # Nodes to look for when discovering the cluster
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- DISABLE_INSTALL_DEMO_CONFIG=true # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- DISABLE_SECURITY_PLUGIN=true # Disables Security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data:/usr/share/opensearch/data # Creates volume called opensearch-data and mounts it to the container
ports:
- 9200:9200 # REST API
- 9600:9600 # Performance Analyzer

opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:latest
container_name: opensearch-dashboards
ports:
- 5601:5601 # Map host port 5601 to container port 5601
expose:
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
environment:
- 'OPENSEARCH_HOSTS=["http://opensearch-node:9200"]'
- DISABLE_SECURITY_DASHBOARDS_PLUGIN=true # disables security dashboards plugin in OpenSearch Dashboards

grants-api:
build:
context: .
Expand All @@ -28,6 +63,8 @@ services:
- .:/api
depends_on:
- grants-db
- opensearch-node

volumes:
grantsdbdata:
opensearch-data:
11 changes: 11 additions & 0 deletions api/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ENVIRONMENT=local
PORT=8080

PERSIST_AUTHORIZATION_OPENAPI=TRUE

# Python path needs to be specified
# for pytest to find the implementation code
PYTHONPATH=/api/
Expand Down Expand Up @@ -59,6 +61,15 @@ DB_SSL_MODE=allow
# could contain sensitive information.
HIDE_SQL_PARAMETER_LOGS=TRUE

############################
# Opensearch Environment Variables
############################

OPENSEARCH_HOST=opensearch-node
OPENSEARCH_PORT=9200
OPENSEARCH_USE_SSL=FALSE
OPENSEARCH_VERIFY_CERTS=FALSE

############################
# AWS Defaults
############################
Expand Down
Loading

0 comments on commit 0d03cb4

Please sign in to comment.