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

Add an init container #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
60 changes: 55 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
services:
init:
profiles: [scaling, fast-updates]
image: flarefoundation/ftso-v2-provider-deployment-init:latest
volumes:
- ./:/app
command: sh -c "cd /app && bash populate_config.sh"

indexer-db:
profiles: [scaling]
container_name: ${COMPOSE_PROJECT_NAME}-indexer-db
Expand All @@ -21,18 +28,44 @@ services:
- ./mounts/indexer/config.toml:/app/config.toml
restart: unless-stopped
depends_on:
init:
condition: service_completed_successfully
indexer-db:
condition: service_healthy

data-provider:
profiles: [scaling]
container_name: ${COMPOSE_PROJECT_NAME}-data-provider
image: ghcr.io/flare-foundation/ftso-scaling:latest
env_file:
- ./mounts/scaling/.env
environment:
- LOG_LEVEL=debug
# Lib config addresses "local-test" | "from-env" | "coston";
- NETWORK=${NETWORK}
# FTSO protocol data provider deploy settings
- DATA_PROVIDER_CLIENT_PORT=3100
- DATA_PROVIDER_CLIENT_BASE_PATH=
- DATA_PROVIDER_CLIENT_API_KEYS=12345,abcdef,abc123
- VOTING_ROUND_HISTORY_SIZE=86400
# DB credentials and settings (for connecting to FSP C-Chain indexer database)
- DB_USERNAME=root
- DB_PASSWORD=root
- DB_HOST=indexer-db
- DB_PORT=3306
- DB_NAME=flare_ftso_indexer
- DB_REQUIRED_INDEXER_HISTORY_TIME_SEC=1209600
- INDEXER_TOP_TIMEOUT=5
# Feed value provider connection url
- VALUE_PROVIDER_BASE_URL=${VALUE_PROVIDER_URL}
- VALUE_PROVIDER_CLIENT_PORT=3101
- VALUE_PROVIDER_CLIENT_BASE_PATH=
command: "node dist/apps/ftso-data-provider/apps/ftso-data-provider/src/main.js"
depends_on:
- indexer
init:
condition: service_completed_successfully
indexer:
condition: service_started
feed-value-provider:
condition: service_started

client:
profiles: [scaling]
Expand All @@ -47,7 +80,21 @@ services:
PROTOCOL_MANAGER_SUBMIT_SIGNATURES_PRIVATE_KEY: ${SIGNATURES_PK}
PROTOCOL_X_API_KEY_100: "abcdef"
depends_on:
- indexer
init:
condition: service_completed_successfully
indexer:
condition: service_started

# !!! Replace image with custom implementation !!!
feed-value-provider:
profiles: [scaling]
container_name: ${COMPOSE_PROJECT_NAME}-feed-value-provider
image: ghcr.io/flare-foundation/ftso-v2-example-value-provider:latest
environment:
- VALUE_PROVIDER_IMPL=fixed
- LOG_LEVEL=debug
- VALUE_PROVIDER_CLIENT_PORT=3101
- VALUE_PROVIDER_CLIENT_BASE_PATH=

fast-updates:
profiles: [fast-updates]
Expand All @@ -60,7 +107,10 @@ services:
ACCOUNTS: ${FAST_UPDATES_ACCOUNTS}
SORTITION_PRIVATE_KEY: ${FAST_UPDATES_SORTITION_PRIVATE_KEY}
depends_on:
- indexer
init:
condition: service_completed_successfully
indexer:
condition: service_started

volumes:
indexer_data:
18 changes: 9 additions & 9 deletions populate_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ main() {

if [ -d "mounts" ] || [ -f "mounts" ]; then
echo "cleaning configs from previous runs:"
echo "rm -r mounts"
rm -r "mounts"
echo "rm -rf mounts/*"
rm -rf "mounts/*"
fi
echo ""

mount_dirs=(
"mounts/client/"
"mounts/indexer/"
"mounts/scaling/"
"mounts/fast-updates/"
)

Expand All @@ -40,7 +39,7 @@ main() {
done
echo ""

echo "writing configs for indexer, client, scaling and fast-updates"
echo "writing configs for indexer, client and fast-updates"

# read contract adresses
export SUBMISSION=$(get_address_by_name "Submission")
Expand Down Expand Up @@ -70,6 +69,12 @@ main() {
-H "Content-Type: application/json" \
--data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' \
| jq -r '.result')

if [ -z "$block_hex" ]; then
echo "ERROR: could not fetch block number from $NODE_RPC_URL"
exit 1
fi

export INDEXER_START_BLOCK=$((16#${block_hex/0x/} - 1000000))

# write configs
Expand All @@ -83,11 +88,6 @@ main() {
mkdir -p "mounts/client"
CONFIG_FILE="mounts/client/config.toml"
envsubst < "template-configs/client.template.toml" > "$CONFIG_FILE"

# scaling
mkdir -p "mounts/scaling"
CONFIG_FILE="mounts/scaling/.env"
envsubst < "template-configs/scaling.env" > "$CONFIG_FILE"

# fast updates
mkdir -p "mounts/fast-updates"
Expand Down
26 changes: 0 additions & 26 deletions template-configs/scaling.env

This file was deleted.