-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2324 from keep-network/docker-my-celo
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:/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. 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.
- Loading branch information
Showing
11 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM golang:1.14-alpine AS gobuild | ||
|
||
RUN apk add --update --no-cache \ | ||
g++ \ | ||
linux-headers \ | ||
make \ | ||
git | ||
|
||
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 /go/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 | ||
# 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 where chain data are persisted | ||
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 $CELO_INIT_DIR | ||
|
||
ADD ./start.sh . | ||
ENTRYPOINT ["./start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Celo client Docker image for local development | ||
|
||
Building the image: | ||
``` | ||
$ docker build -t celo-dev . | ||
``` | ||
|
||
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 | ||
``` | ||
|
||
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: | ||
`$ rm -rf data` and start the container again. Keystore will be automatically | ||
populated and chain genesis executed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
1 change: 1 addition & 0 deletions
1
...it/keystore/UTC--2021-02-10T18-53-12.801965000Z--2b2976824682233807a197081119da511af12f7a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
1 change: 1 addition & 0 deletions
1
...it/keystore/UTC--2021-02-10T18-53-38.775101000Z--a44297a7789725e1ca4824c973d00bef3cdcef02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
1 change: 1 addition & 0 deletions
1
...it/keystore/UTC--2021-02-10T18-55-06.502151000Z--eaec663a8a226e92ea2ff82ba75cf9562dd7a349
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
1 change: 1 addition & 0 deletions
1
...it/keystore/UTC--2021-02-10T18-55-24.803143000Z--ac7ecbf5a908d5bbb8185637f8e5475230f7fc98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
1 change: 1 addition & 0 deletions
1
...it/keystore/UTC--2021-02-10T18-55-40.325817000Z--221df07ac9806020e4ff2ad2003e5f5d64bbaaa4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
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 $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" \ | ||
--mine --miner.threads 1 --nousb \ | ||
--unlock 0x2b2976824682233807a197081119da511af12f7a --password $CELO_DATA_DIR/password.txt \ | ||
--allow-insecure-unlock |