From a9f7cde44dcfc43ccb15f2068f867d51a45ccc90 Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Sat, 25 May 2024 13:25:09 +0200 Subject: [PATCH 1/5] feat: added configuration to use a local token registry --- Dockerfile | 4 + README.md | 10 + docker-compose-local-registry.yml | 172 ++++++++++++++++++ docker-compose.yml | 11 ++ .../src/MetadataClient.ts | 58 +++++- scripts/export_env.sh | 8 +- scripts/token-registry-init.sh | 8 + 7 files changed, 260 insertions(+), 11 deletions(-) create mode 100644 docker-compose-local-registry.yml create mode 100755 scripts/token-registry-init.sh diff --git a/Dockerfile b/Dockerfile index 3c42fca8..ff173abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -113,3 +113,7 @@ COPY config/network/${NETWORK}/cardano-node /config/cardano-node/ WORKDIR /app/packages/server/dist EXPOSE 3100 CMD ["node", "index.js"] + +FROM cardanofoundation/cf-token-metadata-registry-api:latest as token-registry +ADD scripts/token-registry-init.sh /app/entrypoint.sh +ENTRYPOINT sh /app/entrypoint.sh diff --git a/README.md b/README.md index adac6441..24d84552 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,16 @@ docker compose -p preview down +### Use local Token Metadata Registry +The public Token metadata registry has a limit of daily requests, this can lead to long sync times, when resyncing from scratch. +To avoid this we introduced the possibility to use a local token metadata registry. +This will be started within docker-compose and will save all data in an additional schema within the local postgres database. +To start it use the following command: +``` +docker compose -f docker-compose-local-registry.yml up -d +``` +To build all containers from source use `--build`. All environment variables and extra commands can be used as described above. + ### Upgrade Database to Postgres 14 If you are upgrading from Postgres 11 to 14: A resync will be needed. To speed up the process you can use the following snapshots: diff --git a/docker-compose-local-registry.yml b/docker-compose-local-registry.yml new file mode 100644 index 00000000..4fa9fb93 --- /dev/null +++ b/docker-compose-local-registry.yml @@ -0,0 +1,172 @@ +version: "3.8" + +services: + postgres: + image: postgres:${POSTGRES_VERSION:-14.10-alpine} + environment: + - POSTGRES_LOGGING=true + - POSTGRES_DB_FILE=/run/secrets/postgres_db + - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password + - POSTGRES_USER_FILE=/run/secrets/postgres_user + ports: + - ${POSTGRES_PORT:-5432}:5432 + secrets: + - postgres_db + - postgres_password + - postgres_user + shm_size: '2gb' + volumes: + - postgres14-data:/var/lib/postgresql/data + restart: on-failure + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + cardano-node-ogmios: + platform: linux/x86_64 + image: cardanosolutions/cardano-node-ogmios:${OGMIOS_VERSION:-v6.2.0}_${CARDANO_NODE_VERSION:-8.9.0}-${NETWORK:-mainnet} + logging: + driver: "json-file" + options: + max-size: "400k" + max-file: "20" + ports: + - ${OGMIOS_PORT:-1337}:1337 + restart: on-failure + volumes: + - node-db:/db + - node-ipc:/ipc +# Uncomment if you want to use your own config files or the provided ones. +# Current configs are also available at: https://book.world.dev.cardano.org/ +# - ./config/network/${NETWORK:-mainnet}:/config + + cardano-db-sync: + platform: linux/x86_64 + image: ghcr.io/intersectmbo/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-13.2.0.2} + command: [ + "--config", "/config/cardano-db-sync/config.json", + "--socket-path", "/node-ipc/node.socket" + ] + environment: + - POSTGRES_HOST=postgres + - POSTGRES_PORT=5432 + - RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-} + - RESTORE_RECREATE_DB=N + depends_on: + - cardano-node-ogmios + - postgres + secrets: + - postgres_password + - postgres_user + - postgres_db + volumes: + - ./config/network/${NETWORK:-mainnet}:/config + - db-sync-data:/var/lib/cexplorer + - node-ipc:/node-ipc + restart: on-failure + stop_signal: SIGINT + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + hasura: + build: + context: ./packages/api-cardano-db-hasura/hasura + image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.1} + ports: + - ${HASURA_PORT:-8090}:8080 + depends_on: + - "postgres" + restart: on-failure + environment: + - HASURA_GRAPHQL_ENABLE_CONSOLE=true + - HASURA_GRAPHQL_CORS_DOMAIN=http://localhost:9695 + secrets: + - postgres_db + - postgres_password + - postgres_user + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + background: + build: + cache_from: [ cardanofoundation/cardano-graphql-background:latest ] + context: . + target: background + image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} + depends_on: + - "hasura" + - "postgres" + environment: + - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} + - METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://token-metadata-registry:8080} + restart: on-failure + secrets: + - postgres_db + - postgres_password + - postgres_user + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + server: + platform: linux/x86_64 + build: + args: + - NETWORK=${NETWORK:-mainnet} + cache_from: [ inputoutput/cardano-graphql-server:latest ] + context: . + target: server + image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} + environment: + - ALLOW_INTROSPECTION=true + - CACHE_ENABLED=true + - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} + expose: + - ${API_PORT:-3100} + ports: + - ${API_PORT:-3100}:3100 + restart: on-failure + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + token-metadata-registry: + build: + context: . + target: token-registry + ports: + - ${TOKEN_REGISTRY_PORT:-8080}:8080 + environment: + - TOKEN_METADATA_SYNC_JOB=true + - POSTGRES_PORT=${POSTGRES_PORT:-5432} + - POSTGRES_HOST=postgres + - DB_SCHEMA=tokenregistry + secrets: + - postgres_db + - postgres_password + - postgres_user + +secrets: + postgres_db: + file: ./placeholder-secrets/postgres_db + postgres_password: + file: ./placeholder-secrets/postgres_password + postgres_user: + file: ./placeholder-secrets/postgres_user +volumes: + db-sync-data: + node-db: + node-ipc: + postgres14-data: diff --git a/docker-compose.yml b/docker-compose.yml index b95854be..e5116ed8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -142,6 +142,17 @@ services: max-size: "200k" max-file: "10" + token-metadata-registry: + image: cardanofoundation/cf-token-metadata-registry-api:${TOKEN_REGISTRY_TAG:-latest} + ports: + - ${TOKEN_REGISTRY_PORT:-8080}:8080 + environment: + - TOKEN_METADATA_SYNC_JOB=true + - DB_USERNAME=postgres + - DB_PASSWORD=doNoUseThisSecret! + - DB_NAME=cexplorer + - DB_URL=jdbc:postgresql://postgres:${POSTGRES_PORT:-5432}/${DB_NAME:-cexplorer}?currentSchema=token + secrets: postgres_db: file: ./placeholder-secrets/postgres_db diff --git a/packages/api-cardano-db-hasura/src/MetadataClient.ts b/packages/api-cardano-db-hasura/src/MetadataClient.ts index 19efb6b7..13317bb8 100644 --- a/packages/api-cardano-db-hasura/src/MetadataClient.ts +++ b/packages/api-cardano-db-hasura/src/MetadataClient.ts @@ -3,6 +3,7 @@ import { errors, RunnableModuleState } from '@cardano-graphql/util' import { dummyLogger, Logger } from 'ts-log' import { AssetMetadata } from './AssetMetadata' import { Asset } from './graphql_types' +import pRetry from 'p-retry' const MODULE_NAME = 'MetadataFetchClient' @@ -20,16 +21,51 @@ export class MetadataClient { }) } - private async ensureMetadataServerIsAvailable (): Promise { - try { - await this.axiosClient.get('/metadata/healthcheck') - } catch (error) { - if (error.code === 'ENOTFOUND') { - throw new errors.HostDoesNotExist('metadata server') - } else if (error.response?.status !== 404) { - throw error + private async ensureLocalMetadataServerIsAvailable (): Promise { + await pRetry( + async () => { + try { + await this.axiosClient.get('/health') + } catch (error) { + if (error.code === 'ENOTFOUND') { + this.logger.info('Waiting for TokenRegistry to be available') + throw new errors.HostDoesNotExist('metadata server') + } else if (error.response?.status === 400) { // Needed until TokenRegistry is updated + this.logger.info('Token Registry is up') + } else if (error.response?.status !== 404) { + this.logger.info('Metadata Server unreachable.') + throw error + } + } + }, { + factor: 1.5, + retries: 10 } - } + ) + } + + private async waitForLocalMetadataServerSynced (): Promise { + await pRetry( + async () => { + try { + const result = await this.axiosClient.get('/health') + if (!result.data.synced) { + this.logger.info('Metadata registry is still syncing. This can take up to 15min...') + throw new Error('') + } + } catch (error) { + if (error.response?.status === 400) { + this.logger.info('external Registry is up and running') // Needed until TokenRegistry is updated + } else { + throw new Error('') + } + } + }, { + factor: 1.5, + retries: 1000, + minTimeout: 60000 // first try after one minute + } + ) } public async fetch (assetIds: Asset['assetId'][]): Promise { @@ -62,7 +98,9 @@ export class MetadataClient { if (this.state !== null) return this.state = 'initializing' this.logger.info({ module: MODULE_NAME }, 'Initializing') - await this.ensureMetadataServerIsAvailable() + await this.ensureLocalMetadataServerIsAvailable() + this.logger.info({ module: MODULE_NAME }, 'Metadata Server is up and running. Checking Sync Status.') + await this.waitForLocalMetadataServerSynced() this.state = 'initialized' this.logger.info({ module: MODULE_NAME }, 'Initialized') } diff --git a/scripts/export_env.sh b/scripts/export_env.sh index 9ea9863d..2e8dd7b8 100755 --- a/scripts/export_env.sh +++ b/scripts/export_env.sh @@ -11,10 +11,11 @@ case "$NETWORK" in mainnet) API_PORT=3100 HASURA_PORT=8090 - METADATA_SERVER_URI="https://tokens.cardano.org" + METADATA_SERVER_URI="http://localhost:8080" OGMIOS_PORT=1337 PG_ADMIN_PORT=8442 POSTGRES_PORT=5432 + TOKEN_REGISTRY_PORT=8080 ;; testnet) API_PORT=3101 @@ -23,6 +24,7 @@ case "$NETWORK" in OGMIOS_PORT=1338 PG_ADMIN_PORT=8443 POSTGRES_PORT=5443 + TOKEN_REGISTRY_PORT=8081 export CARDANO_NODE_VERSION=8.7.3 ;; preprod) @@ -32,6 +34,7 @@ case "$NETWORK" in OGMIOS_PORT=1339 PG_ADMIN_PORT=8444 POSTGRES_PORT=5444 + TOKEN_REGISTRY_PORT=8082 ;; preview) API_PORT=3103 @@ -40,6 +43,7 @@ case "$NETWORK" in OGMIOS_PORT=1340 PG_ADMIN_PORT=8445 POSTGRES_PORT=5445 + TOKEN_REGISTRY_PORT=8083 ;; vasil-dev) API_PORT=3104 @@ -48,6 +52,7 @@ case "$NETWORK" in OGMIOS_PORT=1341 PG_ADMIN_PORT=8446 POSTGRES_PORT=5446 + TOKEN_REGISTRY_PORT=8084 ;; esac @@ -70,3 +75,4 @@ export PG_ADMIN_PORT export POSTGRES_PORT export POSTGRES_USER_FILE=${SECRETS_DIR}/postgres_user export POSTGRES_HOST=localhost +export TOKEN_REGISTRY_TAG=latest diff --git a/scripts/token-registry-init.sh b/scripts/token-registry-init.sh new file mode 100755 index 00000000..53829989 --- /dev/null +++ b/scripts/token-registry-init.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export DB_USERNAME=$(cat /run/secrets/postgres_user) +export DB_PASSWORD=$(cat /run/secrets/postgres_password) +export DB_NAME=$(cat /run/secrets/postgres_db) +export DB_URL=jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${DB_NAME}?currentSchema=${DB_SCHEMA} + +java -jar /app/app.jar \ No newline at end of file From eac552a8e509ffd6f4362a3c2a221d387e29a15f Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Tue, 28 May 2024 17:17:39 +0200 Subject: [PATCH 2/5] feat: made local token registry default. --- Dockerfile | 3 +- README.md | 10 +- docker-compose-local-registry.yml | 172 ------------------------------ docker-compose.yml | 15 ++- 4 files changed, 16 insertions(+), 184 deletions(-) delete mode 100644 docker-compose-local-registry.yml diff --git a/Dockerfile b/Dockerfile index ff173abd..e71f0f4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,7 +59,8 @@ WORKDIR /src FROM ubuntu-nodejs as background ARG NETWORK=mainnet -ARG METADATA_SERVER_URI="https://tokens.cardano.org" +# using local token registry as default +ARG METADATA_SERVER_URI="localhost:8080" RUN apt-get update -y && apt-get install lsb-release -y RUN curl --proto '=https' --tlsv1.2 -sSf -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - &&\ echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list &&\ diff --git a/README.md b/README.md index 24d84552..b9def4f7 100644 --- a/README.md +++ b/README.md @@ -207,15 +207,13 @@ docker compose -p preview down -### Use local Token Metadata Registry +### Use global Token Metadata Registry The public Token metadata registry has a limit of daily requests, this can lead to long sync times, when resyncing from scratch. -To avoid this we introduced the possibility to use a local token metadata registry. -This will be started within docker-compose and will save all data in an additional schema within the local postgres database. -To start it use the following command: +If it's still needed to run with the global environment it's possible by removing the `token-metadata-registry` from `docker-compose.yml`. +And start it with: ``` -docker compose -f docker-compose-local-registry.yml up -d +METADATA_SERVER_URI="https://tokens.cardano.org" docker compose up -d ``` -To build all containers from source use `--build`. All environment variables and extra commands can be used as described above. ### Upgrade Database to Postgres 14 If you are upgrading from Postgres 11 to 14: A resync will be needed. diff --git a/docker-compose-local-registry.yml b/docker-compose-local-registry.yml deleted file mode 100644 index 4fa9fb93..00000000 --- a/docker-compose-local-registry.yml +++ /dev/null @@ -1,172 +0,0 @@ -version: "3.8" - -services: - postgres: - image: postgres:${POSTGRES_VERSION:-14.10-alpine} - environment: - - POSTGRES_LOGGING=true - - POSTGRES_DB_FILE=/run/secrets/postgres_db - - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password - - POSTGRES_USER_FILE=/run/secrets/postgres_user - ports: - - ${POSTGRES_PORT:-5432}:5432 - secrets: - - postgres_db - - postgres_password - - postgres_user - shm_size: '2gb' - volumes: - - postgres14-data:/var/lib/postgresql/data - restart: on-failure - logging: - driver: "json-file" - options: - max-size: "200k" - max-file: "10" - - cardano-node-ogmios: - platform: linux/x86_64 - image: cardanosolutions/cardano-node-ogmios:${OGMIOS_VERSION:-v6.2.0}_${CARDANO_NODE_VERSION:-8.9.0}-${NETWORK:-mainnet} - logging: - driver: "json-file" - options: - max-size: "400k" - max-file: "20" - ports: - - ${OGMIOS_PORT:-1337}:1337 - restart: on-failure - volumes: - - node-db:/db - - node-ipc:/ipc -# Uncomment if you want to use your own config files or the provided ones. -# Current configs are also available at: https://book.world.dev.cardano.org/ -# - ./config/network/${NETWORK:-mainnet}:/config - - cardano-db-sync: - platform: linux/x86_64 - image: ghcr.io/intersectmbo/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-13.2.0.2} - command: [ - "--config", "/config/cardano-db-sync/config.json", - "--socket-path", "/node-ipc/node.socket" - ] - environment: - - POSTGRES_HOST=postgres - - POSTGRES_PORT=5432 - - RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-} - - RESTORE_RECREATE_DB=N - depends_on: - - cardano-node-ogmios - - postgres - secrets: - - postgres_password - - postgres_user - - postgres_db - volumes: - - ./config/network/${NETWORK:-mainnet}:/config - - db-sync-data:/var/lib/cexplorer - - node-ipc:/node-ipc - restart: on-failure - stop_signal: SIGINT - logging: - driver: "json-file" - options: - max-size: "200k" - max-file: "10" - - hasura: - build: - context: ./packages/api-cardano-db-hasura/hasura - image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.1} - ports: - - ${HASURA_PORT:-8090}:8080 - depends_on: - - "postgres" - restart: on-failure - environment: - - HASURA_GRAPHQL_ENABLE_CONSOLE=true - - HASURA_GRAPHQL_CORS_DOMAIN=http://localhost:9695 - secrets: - - postgres_db - - postgres_password - - postgres_user - logging: - driver: "json-file" - options: - max-size: "200k" - max-file: "10" - - background: - build: - cache_from: [ cardanofoundation/cardano-graphql-background:latest ] - context: . - target: background - image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} - depends_on: - - "hasura" - - "postgres" - environment: - - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} - - METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://token-metadata-registry:8080} - restart: on-failure - secrets: - - postgres_db - - postgres_password - - postgres_user - logging: - driver: "json-file" - options: - max-size: "200k" - max-file: "10" - - server: - platform: linux/x86_64 - build: - args: - - NETWORK=${NETWORK:-mainnet} - cache_from: [ inputoutput/cardano-graphql-server:latest ] - context: . - target: server - image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} - environment: - - ALLOW_INTROSPECTION=true - - CACHE_ENABLED=true - - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} - expose: - - ${API_PORT:-3100} - ports: - - ${API_PORT:-3100}:3100 - restart: on-failure - logging: - driver: "json-file" - options: - max-size: "200k" - max-file: "10" - - token-metadata-registry: - build: - context: . - target: token-registry - ports: - - ${TOKEN_REGISTRY_PORT:-8080}:8080 - environment: - - TOKEN_METADATA_SYNC_JOB=true - - POSTGRES_PORT=${POSTGRES_PORT:-5432} - - POSTGRES_HOST=postgres - - DB_SCHEMA=tokenregistry - secrets: - - postgres_db - - postgres_password - - postgres_user - -secrets: - postgres_db: - file: ./placeholder-secrets/postgres_db - postgres_password: - file: ./placeholder-secrets/postgres_password - postgres_user: - file: ./placeholder-secrets/postgres_user -volumes: - db-sync-data: - node-db: - node-ipc: - postgres14-data: diff --git a/docker-compose.yml b/docker-compose.yml index e5116ed8..071730df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -143,15 +143,20 @@ services: max-file: "10" token-metadata-registry: - image: cardanofoundation/cf-token-metadata-registry-api:${TOKEN_REGISTRY_TAG:-latest} + build: + context: . + target: token-registry ports: - ${TOKEN_REGISTRY_PORT:-8080}:8080 environment: - TOKEN_METADATA_SYNC_JOB=true - - DB_USERNAME=postgres - - DB_PASSWORD=doNoUseThisSecret! - - DB_NAME=cexplorer - - DB_URL=jdbc:postgresql://postgres:${POSTGRES_PORT:-5432}/${DB_NAME:-cexplorer}?currentSchema=token + - POSTGRES_PORT=${POSTGRES_PORT:-5432} + - POSTGRES_HOST=postgres + - DB_SCHEMA=tokenregistry + secrets: + - postgres_db + - postgres_password + - postgres_user secrets: postgres_db: From d9c511a6e9490fb25e049118d6bbf434ebe17e93 Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Wed, 29 May 2024 09:31:48 +0200 Subject: [PATCH 3/5] chore: adjusted token registry port to not disturb any process at port 8080, so switched to 8091 --- Dockerfile | 2 +- docker-compose.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e71f0f4c..709e5abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,7 @@ WORKDIR /src FROM ubuntu-nodejs as background ARG NETWORK=mainnet # using local token registry as default -ARG METADATA_SERVER_URI="localhost:8080" +ARG METADATA_SERVER_URI="localhost:8091" RUN apt-get update -y && apt-get install lsb-release -y RUN curl --proto '=https' --tlsv1.2 -sSf -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - &&\ echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list &&\ diff --git a/docker-compose.yml b/docker-compose.yml index 071730df..7aa36289 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -106,7 +106,7 @@ services: - "postgres" environment: - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} - - METADATA_SERVER_URI=${METADATA_SERVER_URI:-https://tokens.cardano.org} + - METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://localhost:8091} restart: on-failure secrets: - postgres_db @@ -147,7 +147,7 @@ services: context: . target: token-registry ports: - - ${TOKEN_REGISTRY_PORT:-8080}:8080 + - ${TOKEN_REGISTRY_PORT:-8091}:8080 environment: - TOKEN_METADATA_SYNC_JOB=true - POSTGRES_PORT=${POSTGRES_PORT:-5432} From 3f7ad2e894d6bf79c23f136abe9a5b4c1a58e137 Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Wed, 29 May 2024 10:30:18 +0200 Subject: [PATCH 4/5] chore: adjusted token registry port --- Dockerfile | 2 +- docker-compose.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 709e5abd..7bb031b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,7 @@ WORKDIR /src FROM ubuntu-nodejs as background ARG NETWORK=mainnet # using local token registry as default -ARG METADATA_SERVER_URI="localhost:8091" +ARG METADATA_SERVER_URI="http://token-metadata-registry:8091" RUN apt-get update -y && apt-get install lsb-release -y RUN curl --proto '=https' --tlsv1.2 -sSf -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - &&\ echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list &&\ diff --git a/docker-compose.yml b/docker-compose.yml index 7aa36289..4fa9fb93 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -106,7 +106,7 @@ services: - "postgres" environment: - LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info} - - METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://localhost:8091} + - METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://token-metadata-registry:8080} restart: on-failure secrets: - postgres_db @@ -147,7 +147,7 @@ services: context: . target: token-registry ports: - - ${TOKEN_REGISTRY_PORT:-8091}:8080 + - ${TOKEN_REGISTRY_PORT:-8080}:8080 environment: - TOKEN_METADATA_SYNC_JOB=true - POSTGRES_PORT=${POSTGRES_PORT:-5432} From 40908fb00756cccb8d68c8afb78bba5ee61e6d59 Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Mon, 3 Jun 2024 15:52:41 +0200 Subject: [PATCH 5/5] feat: added configurability which repository to use for the token-registry --- docker-compose.yml | 7 ++++--- scripts/token-registry-init.sh | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4fa9fb93..46879f64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -76,7 +76,7 @@ services: hasura: build: context: ./packages/api-cardano-db-hasura/hasura - image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.1} + image: cardanofoundation/cardano-graphql-hasura:${CARDANO_GRAPHQL_VERSION:-8.0.3} ports: - ${HASURA_PORT:-8090}:8080 depends_on: @@ -100,7 +100,7 @@ services: cache_from: [ cardanofoundation/cardano-graphql-background:latest ] context: . target: background - image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} + image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.0.3}-${NETWORK:-mainnet} depends_on: - "hasura" - "postgres" @@ -126,7 +126,7 @@ services: cache_from: [ inputoutput/cardano-graphql-server:latest ] context: . target: server - image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.1}-${NETWORK:-mainnet} + image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.0.3}-${NETWORK:-mainnet} environment: - ALLOW_INTROSPECTION=true - CACHE_ENABLED=true @@ -153,6 +153,7 @@ services: - POSTGRES_PORT=${POSTGRES_PORT:-5432} - POSTGRES_HOST=postgres - DB_SCHEMA=tokenregistry + - NETWORK=${NETWORK:-mainnet} secrets: - postgres_db - postgres_password diff --git a/scripts/token-registry-init.sh b/scripts/token-registry-init.sh index 53829989..1e902082 100755 --- a/scripts/token-registry-init.sh +++ b/scripts/token-registry-init.sh @@ -5,4 +5,17 @@ export DB_PASSWORD=$(cat /run/secrets/postgres_password) export DB_NAME=$(cat /run/secrets/postgres_db) export DB_URL=jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${DB_NAME}?currentSchema=${DB_SCHEMA} +case "$NETWORK" in + mainnet) + GITHUB_ORGANIZATION=cardano-foundation + GITHUB_PROJECT_NAME=cardano-token-registry + GITHUB_MAPPINGS_FOLDER=mappings + ;; + preprod|preview|testnet) + GITHUB_ORGANIZATION=input-output-hk + GITHUB_PROJECT_NAME=metadata-registry-testnet + GITHUB_MAPPINGS_FOLDER=registry + ;; +esac +echo Using Github Repository $GITHUB_ORGANIZATION/$GITHUB_PROJECT_NAME as token registry java -jar /app/app.jar \ No newline at end of file