diff --git a/Readme.md b/Readme.md index 4b779b935..7dfa429a5 100644 --- a/Readme.md +++ b/Readme.md @@ -36,6 +36,7 @@ possible solutions. ## Further Reading * [BuildingRunning][BuildingRunning]: Building and running the db-sync node. +* [Docker][Docker]: Instruction for docker-compose, and building the images using nix. * [Example SQL queries][ExampleQueries]: Some example SQL and Haskell/Esqueleto queries. * [SchemaManagement][Schema Management]: How the database schema is managed and modified. * [SQL DB Schema][DB Schema]: The current PostgreSQL DB schema, as generated by the code. @@ -43,6 +44,7 @@ possible solutions. [BuildingRunning]: doc/building-running.md [DB Schema]: https://hydra.iohk.io/job/Cardano/cardano-db-sync/native.haskellPackages.cardano-db.checks.test-db.x86_64-linux/latest/download/1 +[Docker]: doc/docker.md [ExampleQueries]: doc/interesting-queries.md [PostgresView]: https://www.postgresql.org/docs/current/sql-createview.html [Schema Management]: doc/interesting-queries.md diff --git a/doc/docker.md b/doc/docker.md new file mode 100644 index 000000000..45489e05d --- /dev/null +++ b/doc/docker.md @@ -0,0 +1,46 @@ +# Docker + +## Quickstart + +### Clone the repository + +``` +git clone git@github.com:input-output-hk/cardano-db-sync.git +cd cardano-db-sync +``` +### Start `cardano-node`, `postgresql`, and `cardano-db-sync` services using Docker + +``` console +docker-compose up -d && docker-compose logs -f +``` +### :tada + +The PostgreSQL database is exposed on localhost port `5432` + +### To connect to another network: +``` +$ NETWORK=testnet docker-compose up && docker-compose logs -f +``` + +### Take control +Excluding the `NETWORK` ENV will simply just call the `cardano-db-sync` or +`cardano-db-sync-extended` executable as the entrypoint, so you must pass a command and +arguments in this case to provide config at runtime. The `--schema-dir` argument is preset, +so is not required. + +Using Docker run to demonstrate, but can be achieved using `docker-compose` too via +`service.command` +``` +docker run \ + -v $PWD/config/network/mainnet/cardano-db-sync:/config + -v $PWD/config/network/mainnet/genesis:/genesis + -v $PWD/node-ipc:/node-ipc \ + inputoutput/cardano-db-sync \ + run --config /config/config.yaml --socket-path /node-ipc/node.socket # command +``` + +## Build and load image using Nix + +``` +docker load -i $(nix-build -A dockerImage --no-out-link) +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 3b6f4c523..ae0540b9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,9 +24,9 @@ services: max-file: "10" cardano-node: - image: inputoutput/cardano-node:latest + image: inputoutput/cardano-node:1.18.0 environment: - - NETWORK=${NETWORK} + - NETWORK=${NETWORK:-mainnet} volumes: - node-db:/data/db - node-ipc:/ipc @@ -38,9 +38,9 @@ services: max-file: "10" cardano-db-sync: - image: inputoutput/cardano-db-sync:latest + image: inputoutput/cardano-db-sync:3.1.0 environment: - - NETWORK=${NETWORK} + - NETWORK=${NETWORK:-mainnet} - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 depends_on: