-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add entrypoint that customizes DBSync configuration
Updated the custom entrypoint script for the Cardano DB Sync container to include advanced configuration capabilities. Changes were made to `scripts/govtool/custom-cardano-db-sync.entrypoint.sh` to set up necessary environment variables, handle PostgreSQL authentication via a `pgpass` file, and include the path to `db-sync-config.json`. The `scripts/govtool/Makefile` and `scripts/govtool/config/templates/docker-compose.yml.tpl` files were adjusted to support these changes by implementing new build and deployment targets for the custom Cardano DB Sync image and updating the Docker Compose template. These changes ensure the DBSync process uses the correct settings, allowing it to adapt to future updates and ensuring better synchronization with the Cardano blockchain.
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
#!/bin/sh | ||
echo "Custom Cardano DB Sync entrypoint" | ||
# TODO: Add custom logic here | ||
exec "$@" | ||
set -euo pipefail | ||
mkdir -p -m 1777 /tmp | ||
mkdir -p /configuration | ||
CARDANO_NODE_SOCKET_PATH=/node-ipc/node.socket | ||
CARDANO_DB_SYNC_CONFIG_PATH=/configuration/db-sync-config.json | ||
|
||
# set pgpass file | ||
echo "-> Generating PGPASS file" | ||
SECRET_DIR=/run/secrets | ||
POSTGRES_DB=${POSTGRES_DB:-$(< ${SECRET_DIR}/postgres_db)} | ||
POSTGRES_USER=${POSTGRES_USER:-$(< ${SECRET_DIR}/postgres_user)} | ||
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-$(< ${SECRET_DIR}/postgres_password)} | ||
echo "${POSTGRES_HOST}:${POSTGRES_PORT}:${POSTGRES_DB}:${POSTGRES_USER}:${POSTGRES_PASSWORD}" > /configuration/pgpass | ||
chmod 0600 /configuration/pgpass | ||
export PGPASSFILE=/configuration/pgpass | ||
|
||
# wait for cardano node to start | ||
echo -n "-> Waiting for $CARDANO_NODE_SOCKET_PATH" | ||
until [ -S "$CARDANO_NODE_SOCKET_PATH" ]; do | ||
echo -n "." | ||
sleep 10 | ||
done | ||
echo | ||
|
||
# find schema directory | ||
echo "-> Finding schema directory" | ||
SCHEMA_DIR=$(find /nix/store -type d -name '*-schema') | ||
|
||
echo "-> Running Cardano DB Sync" | ||
exec cardano-db-sync \ | ||
--config "$CARDANO_DB_SYNC_CONFIG_PATH" \ | ||
--socket-path "$CARDANO_NODE_SOCKET_PATH" \ | ||
--schema-dir "$SCHEMA_DIR" \ | ||
--state-dir /state \ | ||
$@ | ||
|
||
echo "-> Cleaning up" |