Skip to content

Commit

Permalink
chore(docker): Pin docker deps, add docs
Browse files Browse the repository at this point in the history
- replace latest tag pins in docker-compose
- default to mainnet
- add docker.md
  • Loading branch information
rhyslbw committed Aug 3, 2020
1 parent 0f247ee commit d141507
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Readme.md
Expand Up @@ -36,13 +36,15 @@ 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.
* [Validation][Validation]: Explanation of validation done by the db-sync node and assumptions made.

[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
Expand Down
46 changes: 46 additions & 0 deletions 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)
```
8 changes: 4 additions & 4 deletions docker-compose.yml
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit d141507

Please sign in to comment.