# orchard-maxwells-daemon

Provides a customisable Docker image for running [Maxwell's daemon](https://maxwells-daemon.io/).

## Setup
* Install [docker](https://docs.docker.com/get-docker/)
* Clone this repository
* Copy `.env.shadow` to `.env`

## Running

### Using Local MySQL / Kinesis Endpoint

The docker compose configuration will by default deploy the Maxwell's daemon container
along with a MySQL container and a [localstack](https://github.com/localstack/localstack) container.

The default configuration in `.env.shadow` will automatically configure the Maxwell's container
to read from the MySQL container and stream updates to the Kinesis service running in the localstack container.

```
docker-compose up --build
```

Generating some data and reading it from the local Kinesis endpoint:

```
docker-compose run --rm db mysql -h db -u root -proot -e 'create table test.my_table (id int);'
docker-compose run --rm db mysql -h db -u root -proot -e 'insert into test.my_table (id) values (1);'
SHARD_ITERATOR=$(aws --endpoint-url http://localhost:4566 kinesis get-shard-iterator --stream-name maxwell --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON --output text)
aws --endpoint-url http://localhost:4566 kinesis get-records --shard-iterator $SHARD_ITERATOR | jq -r '.Records[0].Data' | base64 -d
```

### Using External Services

To use an external MySQL database and/or Kinesis stream, amend the environment variables as required and
use docker compose to just start the required services.
