Skip to content

Commit 1a2ac61

Browse files
authored
Merge pull request #126 from iExecBlockchainComputing/feature/build-speed
Enhance build speed by using Docker caching
2 parents 973a3ad + 48d7c9e commit 1a2ac61

File tree

7 files changed

+52
-38
lines changed

7 files changed

+52
-38
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
node_modules/
1+
node_modules/

testchains/nethermind.dockerfile

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
###
22
## docker image build \
33
## --file testchains/nethermind.dockerfile \
4-
## --tag nexus.iex.ec/poco-chain:native-vX.Y.Z-alpha.0 \
4+
## --tag nexus.intra.iex.ec/poco-chain:native-vX.Y.Z-alpha.0-5s \
55
## --build-arg MNEMONIC="actual surround disorder swim upgrade devote digital misery truly verb slide final" \
66
## --build-arg CHAIN_TYPE=native \
77
## --build-arg CHAIN_BLOCK_TIME=5 \
@@ -11,15 +11,7 @@
1111

1212
FROM iexechub/nethermind:1.14.1-patch.0 AS builder
1313

14-
RUN apt-get update && apt-get install bash jq nodejs npm -y
15-
# Add git required to install ethereumjs-abi from github (https://github.com/MetaMask/web3-provider-engine/issues/345)
16-
#
17-
# ├─┬ @truffle/[email protected]
18-
# └─┬ [email protected]
19-
# └─┬ [email protected]
20-
# └─┬ [email protected]
21-
# └── [email protected] (git+https://github.com/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0)
22-
RUN apt-get install git -y
14+
RUN apt-get update && apt-get -y install bash jq nodejs npm git
2315
RUN echo -e "Node: `node -v` - npm: `npm -v`"
2416

2517
###
@@ -38,6 +30,18 @@ RUN echo "CHAIN_BLOCK_TIME: ${CHAIN_BLOCK_TIME}"
3830
ARG CHAIN_FORCE_SEALING=true
3931
RUN echo "CHAIN_FORCE_SEALING: ${CHAIN_FORCE_SEALING}"
4032

33+
###
34+
## Install npm packages
35+
###
36+
WORKDIR /iexec-poco
37+
COPY package.json package-lock.json ./
38+
# Remove ethereumjs-util for sidechains
39+
RUN if [ "${CHAIN_TYPE}" = "native" ] ; \
40+
then \
41+
sed -i '/ethereumjs-util/d' package.json; \
42+
fi
43+
RUN npm ci --production=false
44+
4145
###
4246
## Copy chain config.
4347
###
@@ -53,10 +57,20 @@ RUN if [ "${CHAIN_TYPE}" = "native" ] ; \
5357
fi
5458

5559
###
56-
## Copy PoCo contracts
60+
## Copy project files
61+
## Copy only needed files to make use
62+
## of Docker's build cache.
5763
###
58-
COPY . /iexec-poco
59-
RUN mv /iexec-poco/config/config_${CHAIN_TYPE}.json /iexec-poco/config/config.json
64+
COPY config config
65+
COPY contracts contracts
66+
COPY migrations migrations
67+
COPY scripts scripts
68+
COPY utils utils
69+
COPY truffle-security.json truffle-security.json
70+
COPY truffle.js truffle.js
71+
COPY testchains/nethermind/migrate-all.sh migrate-all.sh
72+
COPY testchains/nethermind/migrate.sh migrate.sh
73+
RUN mv config/config_${CHAIN_TYPE}.json config/config.json
6074

6175
###
6276
## Deploy contracts
@@ -69,19 +83,20 @@ RUN echo "MNEMONIC: ${MNEMONIC}"
6983
# token -> migrate-all.sh
7084
RUN if [ "${CHAIN_TYPE}" = "native" ] ; \
7185
then \
72-
echo "Migration file: ${BASE_DIR}/migrate.sh"; \
73-
bash /iexec-poco/testchains/nethermind/migrate.sh; \
86+
echo "Migration file: migrate.sh"; \
87+
bash migrate.sh; \
7488
else \
75-
echo "Migration file: ${BASE_DIR}/migrate-all.sh"; \
76-
bash /iexec-poco/testchains/nethermind/migrate-all.sh; \
89+
echo "Migration file: migrate-all.sh"; \
90+
bash migrate-all.sh; \
7791
fi
7892

7993
FROM iexechub/nethermind:1.14.1-patch.0
8094

8195
COPY --from=builder /nethermind /nethermind
96+
COPY --from=builder /iexec-poco/build /build
8297

8398
###
8499
## Configure entrypoint
85100
###
86101
ENTRYPOINT [ "/nethermind/Nethermind.Runner" ]
87-
CMD [ "--config=/nethermind/configs/poco-chain.cfg" ]
102+
CMD [ "--config poco-chain" ]

testchains/nethermind/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This folder contains a ready to use docker-compose file that starts:
2+
* `poco-chain` service. Accessible on http://localhost:8545/
3+
* `netstats` dashboard to monitor the network status. Accessible on http://localhost:8080.
4+
* `grafana` to display gas usage and other metrics of the chain. Accessible on http://localhost:8081.
5+
* `prometheus` and `pushgateway` used to collect metrics from `poco-chain`.
6+
7+
Note: uncomment Docker volumes in compose file to persist data.

testchains/nethermind/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ volumes:
77

88
services:
99
poco-chain:
10-
image: nexus.intra.iex.ec/poco-chain:native-v5.4.0-alpha.0-5s
10+
image: nexus.intra.iex.ec/poco-chain:<tag>
1111
container_name: poco-chain
1212
environment:
1313
# Netstats
@@ -28,7 +28,7 @@ services:
2828
- pushgateway
2929

3030
netstats:
31-
image: docker-regis.iex.ec/netstats:0.0.9
31+
image: docker-regis.iex.ec/netstats:0.0.10
3232
container_name: netstats
3333
ports:
3434
- 8080:3000
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#!/usr/bin/env bash
2-
echo "========== STARTING BLOCKCHAIN =========="
32

4-
/nethermind/Nethermind.Runner --config=/nethermind/configs/poco-chain.cfg > /nethermind/chain.log 2>&1 &
3+
echo "### Starting chain"
4+
/nethermind/Nethermind.Runner --config poco-chain &> /nethermind/chain.log &
55

66
# Wait for the chain to start
77
sleep 5
88

99
# Install node packages and deploy PoCo's smart contracts
10+
echo "### Running migration"
1011
cd /iexec-poco && \
11-
echo "========== INSTALL DEPENDENCIES ==========" && \
12-
bash -i -c "npm ci --production=false" && \
1312
echo "========== STANDARD DEPLOYMENT ==========" && \
1413
jq . config/config.json && \
1514
bash -i -c "./node_modules/.bin/truffle migrate" && \
@@ -18,8 +17,4 @@ cd /iexec-poco && \
1817
rm -R build && \
1918
echo "========== ENTERPRISE DEPLOYMENT ==========" && \
2019
jq . config/config.json && \
21-
bash -i -c "KYC=1 PROXY_SALT=0x0000000000000000000000000000000000000000000000000000000000000001 ./node_modules/.bin/truffle migrate" && \
22-
rm -R build && \
23-
echo "========== CLEANUP ==========" && \
24-
rm -R contracts && \
25-
echo "========== DONE ==========";
20+
bash -i -c "KYC=1 PROXY_SALT=0x0000000000000000000000000000000000000000000000000000000000000001 ./node_modules/.bin/truffle migrate"

testchains/nethermind/migrate.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#!/usr/bin/env bash
22

3-
/nethermind/Nethermind.Runner --config=/nethermind/configs/poco-chain.cfg > /nethermind/chain.log 2>&1 &
3+
echo "### Starting chain"
4+
/nethermind/Nethermind.Runner --config poco-chain &> /nethermind/chain.log &
45

56
# Wait for the chain to start
67
sleep 5
78

89
# Install node packages and deploy PoCo's smart contracts
9-
cd /iexec-poco && \
10-
sed -i '/ethereumjs-util/d' package.json && \
11-
bash -i -c "npm ci --production=false" && \
12-
bash -i -c "./node_modules/.bin/truffle migrate" && \
13-
rm -R contracts && \
14-
rm -R build
10+
echo "### Running migration"
11+
cd /iexec-poco && bash -i -c "./node_modules/.bin/truffle migrate"

testchains/nethermind/poco-chain.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"Name": "Nethermind PoCo Chain",
2727
},
2828
"Metrics": {
29-
"NodeName": "Nethermind Bellecour",
29+
"NodeName": "Nethermind PoCo Chain",
3030
},
3131
"Bloom": {
3232
"IndexLevelBucketSizes": [

0 commit comments

Comments
 (0)