From bd4529ad00192de429f5e79d2b78aec751a0e72d Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Wed, 10 Feb 2021 21:31:22 +0100 Subject: [PATCH 01/12] Docker image for building celo blockchain client for development Setting up Celo client locally for development is similar to setting up Ethereum client locally, except that we need to use specially prepared genesis file which is more complex than one for Ethereum. The process of setting up keystore and doing chain genesis is similar as for Ethereum client. Not very complex but time consuming and cumbersome. The Docker image implemented here should help with this process. A developer needs to build the image: docker build -t celo-dev . And can later start Celo blockchain locally with: docker run -it -v $(pwd)/data:/data -p 8545:8545 -p 8546:8546 celo-dev $(pwd)/data directory is where the chain data will be stored. Since it is a Docker volume, chain data survives container restarts. In case the developer wants to start from a fresh chain, it is enough to remove chain data: rm -rf data/celo or even remove the entire data directory: rm -rf data and start the container again: docker run -it -v $(pwd)/data:/data -p 8545:8545 -p 8546:8546 celo-dev Keystore will be automatically populated and chain genesis executed. --- docker/celo/Dockerfile | 31 +++++++++++ docker/celo/init/genesis.json | 54 +++++++++++++++++++ ...--2b2976824682233807a197081119da511af12f7a | 1 + ...--a44297a7789725e1ca4824c973d00bef3cdcef02 | 1 + ...--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 | 1 + ...--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 | 1 + ...--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 | 1 + docker/celo/init/password.txt | 1 + docker/celo/start.sh | 16 ++++++ 9 files changed, 107 insertions(+) create mode 100644 docker/celo/Dockerfile create mode 100644 docker/celo/init/genesis.json create mode 100644 docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a create mode 100644 docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 create mode 100644 docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 create mode 100644 docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 create mode 100644 docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 create mode 100644 docker/celo/init/password.txt create mode 100755 docker/celo/start.sh diff --git a/docker/celo/Dockerfile b/docker/celo/Dockerfile new file mode 100644 index 0000000000..1e1fcc4cb1 --- /dev/null +++ b/docker/celo/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.14-alpine AS gobuild + +RUN apk add --update --no-cache \ + g++ \ + linux-headers \ + make \ + git + +ENV BIN_PATH=/usr/local/bin \ + DATA_DIR=/data + +VOLUME [$DATA_DIR] + +# Clone, compile, and install Celo blockchain v1.2.2 +RUN git clone https://github.com/celo-org/celo-blockchain.git +WORKDIR celo-blockchain +RUN git checkout v1.2.2 +RUN make geth-musl +RUN cp build/bin/geth $BIN_PATH + +FROM alpine:3.10 +ENV BIN_PATH=/usr/local/bin + +COPY --from=gobuild $BIN_PATH/geth $BIN_PATH + +# Add init directory. It contains genesis.json file and keystore used +# in start.sh +ADD ./init /init + +ADD ./start.sh . +ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/docker/celo/init/genesis.json b/docker/celo/init/genesis.json new file mode 100644 index 0000000000..f9d2224ab7 --- /dev/null +++ b/docker/celo/init/genesis.json @@ -0,0 +1,54 @@ +{ + "config": { + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "chainId": 1101, + "istanbul": { + "policy": 2, + "requesttimeout": 3000, + "epoch": 10, + "lookbackwindow": 2 + } + }, + "nonce": "0x0", + "timestamp": "0x5b843511", + "gasLimit": "0x8000000", + "extraData": "0xecc833a7747eaa8327335e8e0c6b6d8aa3a38d0063591e43ce116ccf5c89753ef9018ad5942b2976824682233807a197081119da511af12f7af862b860a2d1920d598e6b84bbc66e5fcf061f2eedde628b209f49bc0a08048e561e870a17b48c76d14eddcc5903826ac66f9b0012cdbea15ec09bb026ba784bfc89eb6971e41a83fdc7d8ff9a3fa75f26c5e2493f93df2d768e6a7be21b27945a416c0080b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f86480b86000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080f86480b86000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080", + "difficulty": "0x1", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "2b2976824682233807a197081119da511af12f7a": { + "balance": "20000000000000000000000000" + }, + "a44297a7789725e1ca4824c973d00bef3cdcef02": { + "balance": "20000000000000000000000000" + }, + "eaec663a8a226e92ea2ff82ba75cf9562dd7a349": { + "balance": "20000000000000000000000000" + }, + "ac7ecbf5a908d5bbb8185637f8e5475230f7fc98": { + "balance": "20000000000000000000000000" + }, + "221df07ac9806020e4ff2ad2003e5f5d64bbaaa4": { + "balance": "20000000000000000000000000" + }, + "000000000000000000000000000000000000ce10": { + "code": "0x60806040526004361061004a5760003560e01c806303386ba3146101e757806342404e0714610280578063bb913f41146102d7578063d29d44ee14610328578063f7e6af8014610379575b6000600160405180807f656970313936372e70726f78792e696d706c656d656e746174696f6e00000000815250601c019050604051809103902060001c0360001b9050600081549050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610136576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4e6f20496d706c656d656e746174696f6e20736574000000000000000000000081525060200191505060405180910390fd5b61013f816103d0565b6101b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f496e76616c696420636f6e74726163742061646472657373000000000000000081525060200191505060405180910390fd5b60405136810160405236600082376000803683855af43d604051818101604052816000823e82600081146101e3578282f35b8282fd5b61027e600480360360408110156101fd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561023a57600080fd5b82018360208201111561024c57600080fd5b8035906020019184600183028401116401000000008311171561026e57600080fd5b909192939192939050505061041b565b005b34801561028c57600080fd5b506102956105c1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102e357600080fd5b50610326600480360360208110156102fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061060d565b005b34801561033457600080fd5b506103776004803603602081101561034b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107bd565b005b34801561038557600080fd5b5061038e610871565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561041257506000801b8214155b92505050919050565b610423610871565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f73656e64657220776173206e6f74206f776e657200000000000000000000000081525060200191505060405180910390fd5b6104cc8361060d565b600060608473ffffffffffffffffffffffffffffffffffffffff168484604051808383808284378083019250505092505050600060405180830381855af49150503d8060008114610539576040519150601f19603f3d011682016040523d82523d6000602084013e61053e565b606091505b508092508193505050816105ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f696e697469616c697a6174696f6e2063616c6c6261636b206661696c6564000081525060200191505060405180910390fd5b5050505050565b600080600160405180807f656970313936372e70726f78792e696d706c656d656e746174696f6e00000000815250601c019050604051809103902060001c0360001b9050805491505090565b610615610871565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f73656e64657220776173206e6f74206f776e657200000000000000000000000081525060200191505060405180910390fd5b6000600160405180807f656970313936372e70726f78792e696d706c656d656e746174696f6e00000000815250601c019050604051809103902060001c0360001b9050610701826103d0565b610773576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f496e76616c696420636f6e74726163742061646472657373000000000000000081525060200191505060405180910390fd5b8181558173ffffffffffffffffffffffffffffffffffffffff167fab64f92ab780ecbf4f3866f57cee465ff36c89450dcce20237ca7a8d81fb7d1360405160405180910390a25050565b6107c5610871565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610865576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f73656e64657220776173206e6f74206f776e657200000000000000000000000081525060200191505060405180910390fd5b61086e816108bd565b50565b600080600160405180807f656970313936372e70726f78792e61646d696e000000000000000000000000008152506013019050604051809103902060001c0360001b9050805491505090565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610960576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f6f776e65722063616e6e6f74206265203000000000000000000000000000000081525060200191505060405180910390fd5b6000600160405180807f656970313936372e70726f78792e61646d696e000000000000000000000000008152506013019050604051809103902060001c0360001b90508181558173ffffffffffffffffffffffffffffffffffffffff167f50146d0e3c60aa1d17a70635b05494f864e86144a2201275021014fbf08bafe260405160405180910390a2505056fea265627a7a72315820c6403df0b5e902e1433550bf213a8db6f228d5f274ea53241fc8fee572c1703464736f6c634300050d0032", + "storage": { + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "2b2976824682233807a197081119da511af12f7a" + }, + "balance": "0" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a b/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a new file mode 100644 index 0000000000..34c74842a1 --- /dev/null +++ b/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a @@ -0,0 +1 @@ +{"address":"2b2976824682233807a197081119da511af12f7a","blspublickey":"a2d1920d598e6b84bbc66e5fcf061f2eedde628b209f49bc0a08048e561e870a17b48c76d14eddcc5903826ac66f9b0012cdbea15ec09bb026ba784bfc89eb6971e41a83fdc7d8ff9a3fa75f26c5e2493f93df2d768e6a7be21b27945a416c00","crypto":{"cipher":"aes-128-ctr","ciphertext":"35364b63fd04df37ab232631e7a6c0de92661a2c7356c70d57565f61400a8955","cipherparams":{"iv":"99ede6ebba0485b5a911d3acc2962695"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"8cb316db77ed19e21f0279c9316fc0f6f005cd41c49287e94b8522a70c6f2638"},"mac":"ef45d91ee9dc73180f5c80eee4f75d293e66d0d017417f22ac77d8d5957b490d"},"id":"535acdcd-b935-4bbc-9097-d21d97aefab0","version":3} \ No newline at end of file diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 b/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 new file mode 100644 index 0000000000..b5f2fe4233 --- /dev/null +++ b/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 @@ -0,0 +1 @@ +{"address":"a44297a7789725e1ca4824c973d00bef3cdcef02","blspublickey":"70fe7d8c0d0520166b022c34e6b9f54448717e56953ee53d37cd4b982b03de39ad9ac88f69558d32920bae692067250017c0df65af5691d037862cd34303246b43199f7e5cbb2df35c81a8fc1ab8fc038d9f59d19f26161e4caa3991026f1b81","crypto":{"cipher":"aes-128-ctr","ciphertext":"864b3f3359aeee203b5807c275643c6574557b40c33e2aa128dfa1c9b9544540","cipherparams":{"iv":"26a67e5c1d95bb7f8473ea9a785068a1"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"4c2e0904009891125cb109675f29231eede8a8923405e0ab83fc28db4923041c"},"mac":"cce303384cef8cd13498329c444cf4162b2d425952a8c6a0f1c54bfca85081e6"},"id":"d5099a43-e87b-4352-bdf0-45b47f83e868","version":3} \ No newline at end of file diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 b/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 new file mode 100644 index 0000000000..02d481eb3c --- /dev/null +++ b/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 @@ -0,0 +1 @@ +{"address":"eaec663a8a226e92ea2ff82ba75cf9562dd7a349","blspublickey":"83a349c53aa53a9180ae1374790d6a9297f17744ce41026bf92c02f78bacb86634ab92f5bd1b17b9ddde57b12681cd008cd484d21c38a4a506190dcff11571e2dcaa2c78d17e05df1de92585bd6bd665ee9f4994ba1e88189794f96cfc019980","crypto":{"cipher":"aes-128-ctr","ciphertext":"ac8fb03b22cc1bc5381e972ac36a423a4cd7d3af9ddd0c7ed215a66553db1ddf","cipherparams":{"iv":"33dce6d740b9a79cbbeabd94c494901d"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"3efd9d3e78e13780374fb39c1bb79ab0aa1f75b53fdac181f8924aa7a31babc5"},"mac":"b2a05e8a4e99ace61fe96b6acccb89113d4b807737a8ed68c762f9cff6f56ae2"},"id":"5ebc2164-a049-4d28-89a6-02c5cd0867b2","version":3} \ No newline at end of file diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 b/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 new file mode 100644 index 0000000000..300fe56866 --- /dev/null +++ b/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 @@ -0,0 +1 @@ +{"address":"ac7ecbf5a908d5bbb8185637f8e5475230f7fc98","blspublickey":"a58b8aabf24dc7f5d5589ae5043e5519c121986d6645789ea4985d0ddac408ae9a3d1f905647053066fc4959436f9a01cb4c5f3618694206e5ef1dd956249e6c2d8cc7acf2aebe37375fc694e0d8d5b253cb7416c4da4e4e851b40631a538c81","crypto":{"cipher":"aes-128-ctr","ciphertext":"c54dd02d46cc9de3006397540e629d456d0beeb3a0c7432f33ad7bcbd397b1c0","cipherparams":{"iv":"70f518b531538131c03fd8f9b0165752"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1204576b048aef2493bb9ac6e491826d446d74ac4f422272495de3398a82efc1"},"mac":"51953920976b973ab26f43b5cebab82c78ab48b197c86e58af9ada644d6db65b"},"id":"8a51bb80-26dd-4098-8159-1157646a036b","version":3} \ No newline at end of file diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 b/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 new file mode 100644 index 0000000000..8b54856bd3 --- /dev/null +++ b/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 @@ -0,0 +1 @@ +{"address":"221df07ac9806020e4ff2ad2003e5f5d64bbaaa4","blspublickey":"9872250ff23f712414e0978993d8f25a8a370fbe7577d538f5f931d8120c5a785ca6b9170bff1916848b1f686a3f7b01972fb92d3f1fd34efe72611d101cb1510e035521b586b3a91e9f553913c1de6dddb21164851c9581b13b57466f292780","crypto":{"cipher":"aes-128-ctr","ciphertext":"c740e938f956e35400b7c53cfc08565187afcdd48b2d820c31e78e45bf86bfe0","cipherparams":{"iv":"26552fb23a1376a0fb516805ad0dd091"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"d66def803968039a05f001458017634990013b09fdda4f661a7e8be461f01a46"},"mac":"f573adff5047f2a101bec74d1781984209b2a7969a91157007d0cb529832372c"},"id":"1a4e3825-5f65-4a0b-92b0-cbc2822b7ced","version":3} \ No newline at end of file diff --git a/docker/celo/init/password.txt b/docker/celo/init/password.txt new file mode 100644 index 0000000000..f3097ab130 --- /dev/null +++ b/docker/celo/init/password.txt @@ -0,0 +1 @@ +password diff --git a/docker/celo/start.sh b/docker/celo/start.sh new file mode 100755 index 0000000000..5e4267441e --- /dev/null +++ b/docker/celo/start.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +mkdir -p /data/keystore +cp init/keystore/* /data/keystore +cp init/password.txt /data/password.txt +[ ! -d "/data/celo" ] && geth --nousb --datadir=/data init init/genesis.json + + geth --port 3000 --networkid 1101 --identity "somerandomidentity" \ + --ws --wsaddr "0.0.0.0" --wsport "8546" --wsorigins "*" \ + --rpc --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "" \ + --rpcapi "db,ssh,miner,admin,eth,net,web3,personal" \ + --wsapi "db,ssh,miner,admin,eth,net,web3,personal" \ + --datadir /data --syncmode "fast" \ + --mine --miner.threads 1 --nousb \ + --unlock 0x2b2976824682233807a197081119da511af12f7a --password data/password.txt \ + --allow-insecure-unlock \ No newline at end of file From fef1e999adbc17ac5876c18392829b98658a2435 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Wed, 10 Feb 2021 22:12:06 +0100 Subject: [PATCH 02/12] Moved Celo Docker image to infrastructure directory --- {docker => infrastructure/docker}/celo/Dockerfile | 0 {docker => infrastructure/docker}/celo/init/genesis.json | 0 ...T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a | 0 ...T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 | 0 ...T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 | 0 ...T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 | 0 ...T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 | 0 {docker => infrastructure/docker}/celo/init/password.txt | 0 {docker => infrastructure/docker}/celo/start.sh | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {docker => infrastructure/docker}/celo/Dockerfile (100%) rename {docker => infrastructure/docker}/celo/init/genesis.json (100%) rename {docker => infrastructure/docker}/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a (100%) rename {docker => infrastructure/docker}/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 (100%) rename {docker => infrastructure/docker}/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 (100%) rename {docker => infrastructure/docker}/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 (100%) rename {docker => infrastructure/docker}/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 (100%) rename {docker => infrastructure/docker}/celo/init/password.txt (100%) rename {docker => infrastructure/docker}/celo/start.sh (100%) diff --git a/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile similarity index 100% rename from docker/celo/Dockerfile rename to infrastructure/docker/celo/Dockerfile diff --git a/docker/celo/init/genesis.json b/infrastructure/docker/celo/init/genesis.json similarity index 100% rename from docker/celo/init/genesis.json rename to infrastructure/docker/celo/init/genesis.json diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a b/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a similarity index 100% rename from docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a rename to infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 b/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 similarity index 100% rename from docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 rename to infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 b/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 similarity index 100% rename from docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 rename to infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 b/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 similarity index 100% rename from docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 rename to infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 diff --git a/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 b/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 similarity index 100% rename from docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 rename to infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 diff --git a/docker/celo/init/password.txt b/infrastructure/docker/celo/init/password.txt similarity index 100% rename from docker/celo/init/password.txt rename to infrastructure/docker/celo/init/password.txt diff --git a/docker/celo/start.sh b/infrastructure/docker/celo/start.sh similarity index 100% rename from docker/celo/start.sh rename to infrastructure/docker/celo/start.sh From 8f4b4322fc20038e67e1a1d88c4057d34c6ccb67 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 11 Feb 2021 17:29:14 +0100 Subject: [PATCH 03/12] Reorganized directory structure for Celo docker image /data changed to /mnt/data since this is a mounted Docker volume. /init renamed to /celo-init to be more specific about its purpose. --- infrastructure/docker/celo/Dockerfile | 8 ++++---- .../docker/celo/{init => celo-init}/genesis.json | 0 ...01965000Z--2b2976824682233807a197081119da511af12f7a | 0 ...75101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 | 0 ...02151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 | 0 ...03143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 | 0 ...25817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 | 0 .../docker/celo/{init => celo-init}/password.txt | 0 infrastructure/docker/celo/start.sh | 10 +++++----- 9 files changed, 9 insertions(+), 9 deletions(-) rename infrastructure/docker/celo/{init => celo-init}/genesis.json (100%) rename infrastructure/docker/celo/{init => celo-init}/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a (100%) rename infrastructure/docker/celo/{init => celo-init}/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 (100%) rename infrastructure/docker/celo/{init => celo-init}/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 (100%) rename infrastructure/docker/celo/{init => celo-init}/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 (100%) rename infrastructure/docker/celo/{init => celo-init}/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 (100%) rename infrastructure/docker/celo/{init => celo-init}/password.txt (100%) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index 1e1fcc4cb1..d35ef7fc3a 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -2,12 +2,12 @@ FROM golang:1.14-alpine AS gobuild RUN apk add --update --no-cache \ g++ \ - linux-headers \ + linux-headers \ make \ git ENV BIN_PATH=/usr/local/bin \ - DATA_DIR=/data + DATA_DIR=/mnt/data VOLUME [$DATA_DIR] @@ -23,9 +23,9 @@ ENV BIN_PATH=/usr/local/bin COPY --from=gobuild $BIN_PATH/geth $BIN_PATH -# Add init directory. It contains genesis.json file and keystore used +# Add celo-init directory. It contains genesis.json file and keystore used # in start.sh -ADD ./init /init +ADD ./celo-init /celo-init ADD ./start.sh . ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/infrastructure/docker/celo/init/genesis.json b/infrastructure/docker/celo/celo-init/genesis.json similarity index 100% rename from infrastructure/docker/celo/init/genesis.json rename to infrastructure/docker/celo/celo-init/genesis.json diff --git a/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a b/infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a similarity index 100% rename from infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a rename to infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a diff --git a/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 b/infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 similarity index 100% rename from infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 rename to infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02 diff --git a/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 b/infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 similarity index 100% rename from infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 rename to infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349 diff --git a/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 b/infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 similarity index 100% rename from infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 rename to infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98 diff --git a/infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 b/infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 similarity index 100% rename from infrastructure/docker/celo/init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 rename to infrastructure/docker/celo/celo-init/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4 diff --git a/infrastructure/docker/celo/init/password.txt b/infrastructure/docker/celo/celo-init/password.txt similarity index 100% rename from infrastructure/docker/celo/init/password.txt rename to infrastructure/docker/celo/celo-init/password.txt diff --git a/infrastructure/docker/celo/start.sh b/infrastructure/docker/celo/start.sh index 5e4267441e..edf8088b75 100755 --- a/infrastructure/docker/celo/start.sh +++ b/infrastructure/docker/celo/start.sh @@ -1,16 +1,16 @@ #!/bin/sh mkdir -p /data/keystore -cp init/keystore/* /data/keystore -cp init/password.txt /data/password.txt -[ ! -d "/data/celo" ] && geth --nousb --datadir=/data init init/genesis.json +cp /celo-init/keystore/* /mnt/data/keystore +cp /celo-init/password.txt /mnt/data/password.txt +[ ! -d "/mnt/data/celo" ] && geth --nousb --datadir=/mnt/data init /celo-init/genesis.json geth --port 3000 --networkid 1101 --identity "somerandomidentity" \ --ws --wsaddr "0.0.0.0" --wsport "8546" --wsorigins "*" \ --rpc --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "" \ --rpcapi "db,ssh,miner,admin,eth,net,web3,personal" \ --wsapi "db,ssh,miner,admin,eth,net,web3,personal" \ - --datadir /data --syncmode "fast" \ + --datadir /mnt/data --syncmode "fast" \ --mine --miner.threads 1 --nousb \ - --unlock 0x2b2976824682233807a197081119da511af12f7a --password data/password.txt \ + --unlock 0x2b2976824682233807a197081119da511af12f7a --password /mnt/data/password.txt \ --allow-insecure-unlock \ No newline at end of file From 9f868b767733966a2de9123a029a25e5e9e0d25e Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 11 Feb 2021 19:07:38 +0100 Subject: [PATCH 04/12] Pass CELO_DATA_DIR and CELO_INIT_DIR to start.sh script Instead of hardcoding those paths, we now declare them once and pass to the script as environment variables. --- infrastructure/docker/celo/Dockerfile | 12 +++++++----- infrastructure/docker/celo/start.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index d35ef7fc3a..9b2934f780 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -6,10 +6,7 @@ RUN apk add --update --no-cache \ make \ git -ENV BIN_PATH=/usr/local/bin \ - DATA_DIR=/mnt/data - -VOLUME [$DATA_DIR] +ENV BIN_PATH=/usr/local/bin # Clone, compile, and install Celo blockchain v1.2.2 RUN git clone https://github.com/celo-org/celo-blockchain.git @@ -19,13 +16,18 @@ RUN make geth-musl RUN cp build/bin/geth $BIN_PATH FROM alpine:3.10 + ENV BIN_PATH=/usr/local/bin +ENV CELO_DATA_DIR=/mnt/data +ENV CELO_INIT_DIR=/celo-init + +VOLUME [$CELO_INIT_DIR] COPY --from=gobuild $BIN_PATH/geth $BIN_PATH # Add celo-init directory. It contains genesis.json file and keystore used # in start.sh -ADD ./celo-init /celo-init +ADD ./celo-init $CELO_INIT_DIR ADD ./start.sh . ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/infrastructure/docker/celo/start.sh b/infrastructure/docker/celo/start.sh index edf8088b75..fc5c0b10d4 100755 --- a/infrastructure/docker/celo/start.sh +++ b/infrastructure/docker/celo/start.sh @@ -1,16 +1,16 @@ #!/bin/sh -mkdir -p /data/keystore -cp /celo-init/keystore/* /mnt/data/keystore -cp /celo-init/password.txt /mnt/data/password.txt -[ ! -d "/mnt/data/celo" ] && geth --nousb --datadir=/mnt/data init /celo-init/genesis.json +mkdir -p $CELO_DATA_DIR/keystore +cp $CELO_INIT_DIR/keystore/* $CELO_DATA_DIR/keystore +cp $CELO_INIT_DIR/password.txt $CELO_DATA_DIR/password.txt +[ ! -d "$CELO_DATA_DIR/celo" ] && geth --nousb --datadir=$CELO_DATA_DIR init $CELO_INIT_DIR/genesis.json geth --port 3000 --networkid 1101 --identity "somerandomidentity" \ --ws --wsaddr "0.0.0.0" --wsport "8546" --wsorigins "*" \ --rpc --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "" \ --rpcapi "db,ssh,miner,admin,eth,net,web3,personal" \ --wsapi "db,ssh,miner,admin,eth,net,web3,personal" \ - --datadir /mnt/data --syncmode "fast" \ + --datadir $CELO_DATA_DIR --syncmode "fast" \ --mine --miner.threads 1 --nousb \ - --unlock 0x2b2976824682233807a197081119da511af12f7a --password /mnt/data/password.txt \ + --unlock 0x2b2976824682233807a197081119da511af12f7a --password $CELO_DATA_DIR/password.txt \ --allow-insecure-unlock \ No newline at end of file From c74d28222da61bf53c75e8ee02cfcc25277d34f5 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 11 Feb 2021 19:26:08 +0100 Subject: [PATCH 05/12] README on building local Celo chain image for development --- infrastructure/docker/celo/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 infrastructure/docker/celo/README.md diff --git a/infrastructure/docker/celo/README.md b/infrastructure/docker/celo/README.md new file mode 100644 index 0000000000..7e1790df53 --- /dev/null +++ b/infrastructure/docker/celo/README.md @@ -0,0 +1,19 @@ +# Celo client Docker image for local development + +Building the image: +``` +$ docker build -t celo-dev . +``` + +Starting Celo blockchain locally with the image built: +``` +$ docker run -it -v $(pwd)/data:/data -p 8545:8545 -p 8546:8546 celo-dev +``` + +`$(pwd)/data` directory is where the chain data will be stored. Since it is +a Docker volume, chain data survive container restarts. + +In case the developer wants to start from a fresh chain, it is enough to remove +chain data: `$ rm -rf data/celo`, or even remove the entire data directory: +`$ rm -rf data` and start the container again. Keystore will be automatically +populated and chain genesis executed. \ No newline at end of file From df0b1b5bc5dbd6f7cba2d465a5fcb8cabdb5fc45 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 11 Feb 2021 20:21:08 +0100 Subject: [PATCH 06/12] Updated Celo Docker README with the new CELO_DATA_DIR value CELO_DATA_DIR points now to /mnt/data --- infrastructure/docker/celo/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/docker/celo/README.md b/infrastructure/docker/celo/README.md index 7e1790df53..3068f5412c 100644 --- a/infrastructure/docker/celo/README.md +++ b/infrastructure/docker/celo/README.md @@ -7,7 +7,7 @@ $ docker build -t celo-dev . Starting Celo blockchain locally with the image built: ``` -$ docker run -it -v $(pwd)/data:/data -p 8545:8545 -p 8546:8546 celo-dev +$ docker run -it -v $(pwd)/data:/mnt/data -p 8545:8545 -p 8546:8546 celo-dev ``` `$(pwd)/data` directory is where the chain data will be stored. Since it is @@ -16,4 +16,4 @@ a Docker volume, chain data survive container restarts. In case the developer wants to start from a fresh chain, it is enough to remove chain data: `$ rm -rf data/celo`, or even remove the entire data directory: `$ rm -rf data` and start the container again. Keystore will be automatically -populated and chain genesis executed. \ No newline at end of file +populated and chain genesis executed. From d30eb8ed8b32fa5957543016645e0b87ce9be1de Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 09:50:08 +0100 Subject: [PATCH 07/12] Fixed the name of mounted volume The volume mounted by the host should point to CELO_DATA_DIR, not CELO_INIT_DIR. --- infrastructure/docker/celo/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index 9b2934f780..c9f2e840be 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -21,7 +21,7 @@ ENV BIN_PATH=/usr/local/bin ENV CELO_DATA_DIR=/mnt/data ENV CELO_INIT_DIR=/celo-init -VOLUME [$CELO_INIT_DIR] +VOLUME [$CELO_DATA_DIR] COPY --from=gobuild $BIN_PATH/geth $BIN_PATH From 883735735154a15adca40b003e4b8d8e89c61e10 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 09:54:26 +0100 Subject: [PATCH 08/12] Use an absolute path for WORKDIR It does not change anything but it probably cleaner and editors will stop complaining. --- infrastructure/docker/celo/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index c9f2e840be..aa4d92bd40 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -10,7 +10,7 @@ ENV BIN_PATH=/usr/local/bin # Clone, compile, and install Celo blockchain v1.2.2 RUN git clone https://github.com/celo-org/celo-blockchain.git -WORKDIR celo-blockchain +WORKDIR /go/celo-blockchain RUN git checkout v1.2.2 RUN make geth-musl RUN cp build/bin/geth $BIN_PATH From e7f88d61157b95a81f2aa8c4eac80fa4442b09b9 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 09:55:58 +0100 Subject: [PATCH 09/12] Note which environment variables are used by script.sh --- infrastructure/docker/celo/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index aa4d92bd40..c47cec85bf 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -18,6 +18,7 @@ RUN cp build/bin/geth $BIN_PATH FROM alpine:3.10 ENV BIN_PATH=/usr/local/bin +# Environment variables used in start.sh ENV CELO_DATA_DIR=/mnt/data ENV CELO_INIT_DIR=/celo-init From d25f0693effcf8ed812e661faeb3e1b304f2be79 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 11:46:04 +0100 Subject: [PATCH 10/12] Use EXPOSE instruction for Celo WS and RPC port This way, port numbers are better documented and can be randomly assigned in case when e.g. Ethereum client is running on the host chain on ports 8454/8546. --- infrastructure/docker/celo/Dockerfile | 12 +++++++++--- infrastructure/docker/celo/README.md | 15 ++++++++++++--- infrastructure/docker/celo/start.sh | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index c47cec85bf..bf82da71d7 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -17,17 +17,23 @@ RUN cp build/bin/geth $BIN_PATH FROM alpine:3.10 +# Volume where chain data are persisted +VOLUME [$CELO_DATA_DIR] + ENV BIN_PATH=/usr/local/bin # Environment variables used in start.sh ENV CELO_DATA_DIR=/mnt/data ENV CELO_INIT_DIR=/celo-init +ENV CELO_RPC_PORT=8545 +ENV CELO_WS_PORT=8546 -VOLUME [$CELO_DATA_DIR] +EXPOSE $CELO_RPC_PORT +EXPOSE $CELO_WS_PORT COPY --from=gobuild $BIN_PATH/geth $BIN_PATH -# Add celo-init directory. It contains genesis.json file and keystore used -# in start.sh +# Add celo-init directory. It contains genesis.json file and +# keystore used in start.sh ADD ./celo-init $CELO_INIT_DIR ADD ./start.sh . diff --git a/infrastructure/docker/celo/README.md b/infrastructure/docker/celo/README.md index 3068f5412c..162da255c3 100644 --- a/infrastructure/docker/celo/README.md +++ b/infrastructure/docker/celo/README.md @@ -5,13 +5,22 @@ Building the image: $ docker build -t celo-dev . ``` -Starting Celo blockchain locally with the image built: +Starting Celo blockchain locally exposing ports 8545 and 8546: ``` $ docker run -it -v $(pwd)/data:/mnt/data -p 8545:8545 -p 8546:8546 celo-dev ``` -`$(pwd)/data` directory is where the chain data will be stored. Since it is -a Docker volume, chain data survive container restarts. +Starting Celo blockchain locally with RPC and WS ports randomly assigned +and checking which ports were assigned: +``` +$ docker run -P -it -v $(pwd)/data:/mnt/data --name celo-dev celo-dev +``` + +``` +$ docker port celo-dev +``` + +`$(pwd)/data` directory is where the chain data will be stored. In case the developer wants to start from a fresh chain, it is enough to remove chain data: `$ rm -rf data/celo`, or even remove the entire data directory: diff --git a/infrastructure/docker/celo/start.sh b/infrastructure/docker/celo/start.sh index fc5c0b10d4..b6289e4450 100755 --- a/infrastructure/docker/celo/start.sh +++ b/infrastructure/docker/celo/start.sh @@ -6,8 +6,8 @@ cp $CELO_INIT_DIR/password.txt $CELO_DATA_DIR/password.txt [ ! -d "$CELO_DATA_DIR/celo" ] && geth --nousb --datadir=$CELO_DATA_DIR init $CELO_INIT_DIR/genesis.json geth --port 3000 --networkid 1101 --identity "somerandomidentity" \ - --ws --wsaddr "0.0.0.0" --wsport "8546" --wsorigins "*" \ - --rpc --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "" \ + --ws --wsaddr "0.0.0.0" --wsport $CELO_WS_PORT --wsorigins "*" \ + --rpc --rpcport $CELO_RPC_PORT --rpcaddr "0.0.0.0" --rpccorsdomain "" \ --rpcapi "db,ssh,miner,admin,eth,net,web3,personal" \ --wsapi "db,ssh,miner,admin,eth,net,web3,personal" \ --datadir $CELO_DATA_DIR --syncmode "fast" \ From 77b9df5b4ebf4bd03ccff3aff1edad3efe4632fb Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 11:50:48 +0100 Subject: [PATCH 11/12] Add .gitignore for Celo data directory Developers can point to any directory as a data dir for Celo, but given that $(pwd)/data is what the README mentiones, ignoring data/ by default is good for developer's convenience. --- infrastructure/docker/celo/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 infrastructure/docker/celo/.gitignore diff --git a/infrastructure/docker/celo/.gitignore b/infrastructure/docker/celo/.gitignore new file mode 100644 index 0000000000..8fce603003 --- /dev/null +++ b/infrastructure/docker/celo/.gitignore @@ -0,0 +1 @@ +data/ From 8e836af329295793e02a7268f4efa0502e027b44 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 12 Feb 2021 14:55:40 +0100 Subject: [PATCH 12/12] Declare VOLUME after environment variables are set --- infrastructure/docker/celo/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/infrastructure/docker/celo/Dockerfile b/infrastructure/docker/celo/Dockerfile index bf82da71d7..443cae42ed 100644 --- a/infrastructure/docker/celo/Dockerfile +++ b/infrastructure/docker/celo/Dockerfile @@ -17,9 +17,6 @@ RUN cp build/bin/geth $BIN_PATH FROM alpine:3.10 -# Volume where chain data are persisted -VOLUME [$CELO_DATA_DIR] - ENV BIN_PATH=/usr/local/bin # Environment variables used in start.sh ENV CELO_DATA_DIR=/mnt/data @@ -27,6 +24,9 @@ ENV CELO_INIT_DIR=/celo-init ENV CELO_RPC_PORT=8545 ENV CELO_WS_PORT=8546 +# Volume where chain data are persisted +VOLUME [$CELO_DATA_DIR] + EXPOSE $CELO_RPC_PORT EXPOSE $CELO_WS_PORT