github.com/google/trillian-examples@v0.0.0-20240520080811-0d40d35cef0e/clone/cmd/sumdbclone/README.md (about) 1 # `sumdbclone` 2 3 This tool clones the log for sum.golang.org. 4 See background and database setup in the [parent docs](../../README.md). 5 6 ## Cloning 7 8 Assuming the database is provisioned (with database called `sumdbclone`), the log can be downloaded with: 9 10 ``` 11 go run ./clone/cmd/sumdbclone --alsologtostderr --v=1 --mysql_uri 'clonetool:letmein@tcp(localhost)/sumdbclone' 12 ``` 13 14 ## Docker 15 16 ### SQL DB in Docker 17 18 The `docker-compose` scripts in this directory allow for deployment of the `sumdbclone` tool in a single command: 19 20 ```bash 21 docker compose up -d 22 ``` 23 24 For Raspberry Pi users, there is a slight change in order to override the DB: 25 26 ```bash 27 docker compose -f docker-compose.yaml -f docker-compose.rpi.yaml up -d 28 ``` 29 30 This will bring up two containers: `sumdbclone-db-1` and `sumdbclone-clone-1`. 31 The clone tool will initially run in a batch mode to download all of the entries. 32 To see the status of this, use the following command: 33 34 ```bash 35 docker logs sumdbclone-clone-1 -f 36 37 I0404 10:23:13.018137 1 clone.go:177] 18636.3 leaves/s, last leaf=4700160 (remaining: 12130037, ETA: 10m50s), time working=97.1% 38 ``` 39 40 Once the initial batch clone is complete, the tool will periodically poll the log and clone any new entries. 41 At this time, it is reasonable to start making queries of the database. 42 It is expected that users will write their own tools to query the DB, but the following command demonstrates the leaves being queried from the command line: 43 44 ```bash 45 docker exec -i sumdbclone-db-1 /usr/bin/mysql -usumdb -pletmein -Dsumdb <<< "select * from leaves where id < 5;" 46 ``` 47 48 ### External SQL DB 49 50 To build a docker image, run the following from the `trillian-examples` root directory: 51 52 ``` 53 docker build . -t sumdbclone -f ./clone/cmd/sumdbclone/Dockerfile 54 ``` 55 56 This can be pointed at a local MySQL instance running outside of docker using: 57 58 ``` 59 docker run --name clone_sumdb -d sumdbclone --alsologtostderr --v=1 --mysql_uri 'clonetool:letmein@tcp(host.docker.internal)/sumdbclone' 60 ```