From eac552a8e509ffd6f4362a3c2a221d387e29a15f Mon Sep 17 00:00:00 2001 From: Kammerlo Date: Tue, 28 May 2024 17:17:39 +0200 Subject: [PATCH] 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: