Skip to content

Commit

Permalink
fix: update deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouop0 committed Sep 25, 2024
1 parent a666742 commit 736287c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deploy/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source:
database: dispute_explorer
meilisearch:
api_url: http://localhost:7700
api_key: 56313adcb3ebc9220c6b225f7a17d4a1f84183a64ddecac62d179486ed1f0114
api_key: 2938b40b6c8a907ca74408c51951bd136e50c3f86d6d85a239e83745a89bdf31
sync:
- table: dispute_game
index: disputegames
Expand Down
10 changes: 8 additions & 2 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ services:
restart: always
ports:
- "3367:3306"
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 45s
interval: 10s
retries: 10
volumes:
- ./mysql/datadir:/var/lib/mysql
- ./init.sql:/docker-entrypoint-initdb.d/init.sql

node1:
container_name: dispute-explorer-backend
image: ghcr.io/optimism-java/dispute-explorer:sha-01ae5fc
image: ghcr.io/optimism-java/dispute-explorer:sha-a666742
restart: on-failure
depends_on:
- mysql
mysql:
condition: service_healthy
env_file:
- ../.env
ports:
Expand Down
29 changes: 29 additions & 0 deletions deploy/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,33 @@ new_api_key=$(echo "$curl_response" | jq -r '.results[] | select(.actions[] | co

yq e ".meilisearch.api_key = \"$new_api_key\"" -i config.yml

# Check if curl is installed
if ! [ -x "$(command -v curl)" ]; then
echo 'Error: curl is not installed. Please install curl.' >&2
exit 1
fi

# Start Docker Compose
docker-compose -f docker-compose.yml up -d

sleep 5

# Bearer Token
bearer_token="123456"

# Send request to get API key
curl_response=$(curl -s -H "Authorization: Bearer $bearer_token" http://localhost:7700/keys)
new_api_key=$(echo "$curl_response" | jq -r '.results[] | select(.actions[] | contains("*")) | .key')

sed -i 's/\(api_key:\s*\).*/\1new_api_key_value/' config.yml

echo "api_key was successfully updated to: $new_api_key"

sortable_attributes='["block_number"]'
sortEventUrl="http://localhost:7700/indexes/syncevents/settings/sortable-attributes"
sortEventRsp=$(curl -X PUT $sortEventUrl -H "Content-Type: application/json" -H "Authorization: Bearer $bearer_token" -d "$sortable_attributes")
echo "$sortEventRsp"

sortGamesUrl="http://localhost:7700/indexes/disputegames/settings/sortable-attributes"
sortGamesRsp=$(curl -X PUT $sortGamesUrl -H "Content-Type: application/json" -H "Authorization: Bearer $bearer_token" -d "$sortable_attributes")
echo $sortGamesRsp

0 comments on commit 736287c

Please sign in to comment.