-
Notifications
You must be signed in to change notification settings - Fork 105
Setting up cardano‐graphql and cardano‐rosetta using the same Docker stack
Lincon Vidal edited this page Nov 26, 2024
·
5 revisions
-
Cardano-GraphQL:
git clone \ --single-branch \ --branch 8.3.0 \ --recurse-submodules \ https://github.com/cardano-foundation/cardano-graphql.git \ && cd cardano-graphql
-
Cardano-Rosetta:
git clone \ --single-branch \ --branch 2.4.0 \ https://github.com/cardano-foundation/cardano-rosetta.git
cardano-graphql/cardano-rosetta/Dockerfile
ARG UBUNTU_VERSION=22.04
FROM ubuntu:${UBUNTU_VERSION} AS base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get install -y \
build-essential \
git \
curl \
jq \
lsb-release \
wget \
libffi-dev \
libgmp-dev \
libssl-dev \
libtinfo-dev \
zlib1g-dev
ARG NODEJS_MAJOR_VERSION=18
RUN curl -fsSL https://deb.nodesource.com/setup_${NODEJS_MAJOR_VERSION}.x | bash - && \
apt-get install -y nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn
FROM base as rosetta-server-builder
WORKDIR /app
COPY cardano-rosetta-server/package.json cardano-rosetta-server/yarn.lock ./
RUN yarn install --frozen-lockfile --non-interactive
COPY cardano-rosetta-server/ ./
RUN yarn build
FROM base as cardano-rosetta-server
WORKDIR /app
COPY --from=rosetta-server-builder /app/dist ./dist
COPY --from=rosetta-server-builder /app/node_modules ./node_modules
COPY --from=rosetta-server-builder /app/package.json ./package.json
CMD ["node", "dist/src/server/index.js"]
cardano-graphql/docker-compose.yml
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}:${POSTGRES_PORT:-5432}
command: -p ${POSTGRES_PORT:-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:
image: ghcr.io/intersectmbo/cardano-node:${CARDANO_NODE_VERSION:-10.1.2}
environment:
- NETWORK=${NETWORK:-mainnet}
volumes:
- node-ipc:/ipc
- node-db:/node/db
- ./config/network/${NETWORK:-mainnet}:/config
- cardano-bin:/usr/local/bin
- nix-store:/nix/store
entrypoint: cardano-node run --database-path /node/db --socket-path /ipc/node.socket --topology /config/cardano-node/topology.json --config /config/cardano-node/config.json
ogmios:
image: cardanosolutions/ogmios:${OGMIOS_VERSION:-v6.9.0}
command:
- --host
- 0.0.0.0
- --node-socket
- /ipc/node.socket
- --node-config
- /config/cardano-node/config.json
- --log-level-websocket
- error
volumes:
- node-ipc:/ipc
- ./config/network/${NETWORK:-mainnet}:/config
ports:
- ${OGMIOS_PORT:-1337}:1337
restart: on-failure
cardano-db-sync:
platform: linux/x86_64
image: ghcr.io/intersectmbo/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-13.6.0.1}
command: [
"--config", "/config/cardano-db-sync/config.json",
"--socket-path", "/node-ipc/node.socket"
]
environment:
- POSTGRES_HOST=postgres
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
- RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-}
- RESTORE_RECREATE_DB=N
depends_on:
cardano-node:
condition: service_started
postgres:
condition: service_started
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.3.0}
ports:
- ${HASURA_PORT:-8090}:8080
depends_on:
- "postgres"
restart: on-failure
environment:
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
- HASURA_GRAPHQL_CORS_DOMAIN=http://localhost:9695
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
secrets:
- postgres_db
- postgres_password
- postgres_user
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
background:
build:
context: .
target: background
image: cardanofoundation/cardano-graphql-background:${CARDANO_GRAPHQL_VERSION:-8.3.0}-${NETWORK:-mainnet}
depends_on:
- "hasura"
- "postgres"
environment:
- LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info}
- METADATA_SERVER_URI=${METADATA_SERVER_URI:-http://token-metadata-registry:${TOKEN_REGISTRY_PORT:-8080}}
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
- CHAIN_FOLLOWER_START_SLOT=${CHAIN_FOLLOWER_START_SLOT:-0}
- CHAIN_FOLLOWER_START_ID=${CHAIN_FOLLOWER_START_ID:-}
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}
context: .
target: server
image: cardanofoundation/cardano-graphql-server:${CARDANO_GRAPHQL_VERSION:-8.3.0}-${NETWORK:-mainnet}
environment:
- ALLOW_INTROSPECTION=true
- CACHE_ENABLED=true
- LOGGER_MIN_SEVERITY=${LOGGER_MIN_SEVERITY:-info}
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
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
- NETWORK=${NETWORK:-mainnet}
secrets:
- postgres_db
- postgres_password
- postgres_user
restart: on-failure
depends_on:
- postgres
cardano-rosetta:
build:
context: ./cardano-rosetta/
dockerfile: Dockerfile
entrypoint: [
"node", "dist/src/server/index.js"
]
environment:
- NETWORK=${NETWORK:-mainnet}
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
- DB_CONNECTION_STRING=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}
- GENESIS_SHELLEY_PATH=/config/genesis/shelley.json
- LOGGER_LEVEL=${LOGGER_MIN_SEVERITY:-info}
- PORT=${ROSETTA_PORT:-8077}
- TOPOLOGY_FILE_PATH=/config/cardano-node/topology.json
- CARDANO_CLI_PATH=/usr/local/bin/cardano-cli
- CARDANO_NODE_PATH=/usr/local/bin/cardano-node
- BIND_ADDRESS=0.0.0.0
- CARDANO_NETWORK=${NETWORK:-mainnet}
- DEFAULT_RELATIVE_TTL=1000
- CACHE_TTL=300
- PAGE_SIZE=100
- OGMIOS_HOST=localhost
- OGMIOS_PORT=${OGMIOS_PORT:-1337}
- DEFAULT_POOL_DEPOSIT=500000000
- DEFAULT_KEY_DEPOSIT=2000000
secrets:
- postgres_password
- postgres_user
- postgres_db
volumes:
- node-ipc:/ipc
- ./cardano-rosetta/config/network/${NETWORK:-mainnet}:/config
- cardano-bin:/usr/local/bin
- nix-store:/nix/store
ports:
- ${ROSETTA_PORT:-8077}:8077
depends_on:
- cardano-node
- cardano-db-sync
restart: on-failure
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:
cardano-bin:
nix-store:
-
Edit the credentials in the
placeholder-secrets
directory: Replace the content ofpostgres_password
,postgres_db
, andpostgres_user
with your actual database credentials.
- Build and run the services for the specific network of your choice:
Mainnet
export POSTGRES_PASSWORD=$(cat ./placeholder-secrets/postgres_password) && \
export POSTGRES_DB=$(cat ./placeholder-secrets/postgres_db) && \
export POSTGRES_USER=$(cat ./placeholder-secrets/postgres_user) && \
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
CHAIN_FOLLOWER_START_SLOT=23068800 \
CHAIN_FOLLOWER_START_ID=a650a3f398ba4a9427ec8c293e9f7156d81fd2f7ca849014d8d2c1156c359b3a \
docker compose up -d --build &&\
docker compose logs -f
Disclaimer: The CHAIN_FOLLOWER_START_SLOT
and CHAIN_FOLLOWER_START_ID
environment variables are currently mandatory for the mainnet
. Without these, the Token registry will get stuck. A fix will be provided as soon as possible.
Preprod
export POSTGRES_PASSWORD=$(cat ./placeholder-secrets/postgres_password) && \
export POSTGRES_DB=$(cat ./placeholder-secrets/postgres_db) && \
export POSTGRES_USER=$(cat ./placeholder-secrets/postgres_user) && \
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
NETWORK=preprod \
API_PORT=3101 \
HASURA_PORT=8091 \
OGMIOS_PORT=1338 \
POSTGRES_PORT=5433 \
docker compose -p preprod up -d --build &&\
docker compose -p preprod logs -f
Preview
export POSTGRES_PASSWORD=$(cat ./placeholder-secrets/postgres_password) && \
export POSTGRES_DB=$(cat ./placeholder-secrets/postgres_db) && \
export POSTGRES_USER=$(cat ./placeholder-secrets/postgres_user) && \
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
NETWORK=preview \
API_PORT=3102 \
HASURA_PORT=8092 \
OGMIOS_PORT=1339 \
POSTGRES_PORT=5434 \
docker compose -p preview up -d --build &&\
docker compose -p preview logs -f
Sanchonet
export POSTGRES_PASSWORD=$(cat ./placeholder-secrets/postgres_password) && \
export POSTGRES_DB=$(cat ./placeholder-secrets/postgres_db) && \
export POSTGRES_USER=$(cat ./placeholder-secrets/postgres_user) && \
DOCKER_BUILDKIT=1 \
COMPOSE_DOCKER_CLI_BUILD=1 \
NETWORK=sanchonet \
API_PORT=3102 \
HASURA_PORT=8092 \
OGMIOS_PORT=1339 \
POSTGRES_PORT=5434 \
docker compose -p preview up -d --build &&\
docker compose -p preview logs -f
Note: Ensure you use the appropriate network configuration by selecting the correct environment variables for each network. Refer to the README in the cardano-graphql
repository for more detailed instructions on configuring these settings for other environments.