zkopru-network / zkopru

Ethereum L2 scaling solution for private transactions using zk-SNARK and optimistic rollup.
https://zkopru.network
GNU General Public License v3.0
216 stars 28 forks source link

failed to build docker image on M1 chip #400

Open sifnoc opened 2 years ago

sifnoc commented 2 years ago

Describe the bug This issue reported by Kimi Wu current main branch https://github.com/zkopru-network/zkopru/commit/b50e4cc0d046f58234cb3301099bbb4feddabc66 could not build dockerfiles/Cli.dockerfile on MacOs with M1 chip

To Reproduce yarn develop

Expected behavior build images compose_coordinator, compose_wallet, compose_testnet then run containers for play

$ (sleep 10; open-cli http://localhost:4321) & (sleep 10; open-cli http://localhost:1234) & docker-compose -f compose/docker-compose.dev.yml up --force-recreate -V
Creating network "compose_default" with the default driver
Creating compose_testnet_1 ... done
Creating compose_coordinator_1 ... done
Creating compose_wallet_1      ... done
Attaching to compose_testnet_1, compose_coordinator_1, compose_wallet_1
testnet_1      | Ganache CLI v6.12.2 (ganache-core: 2.13.2)
testnet_1      | 
testnet_1      | Available Accounts
testnet_1      | ==================
testnet_1      | (0) 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1 (100 ETH)
testnet_1      | (1) 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0 (100 ETH)
testnet_1      | (2) 0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b (100 ETH)
testnet_1      | (3) 0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d (100 ETH)
testnet_1      | (4) 0xd03ea8624C8C5987235048901fB614fDcA89b117 (100 ETH)
testnet_1      | (5) 0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC (100 ETH)
testnet_1      | (6) 0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9 (100 ETH)
testnet_1      | (7) 0x28a8746e75304c0780E011BEd21C72cD78cd535E (100 ETH)
testnet_1      | (8) 0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E (100 ETH)
testnet_1      | (9) 0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e (100 ETH)
testnet_1      | 
testnet_1      | Private Keys
testnet_1      | ==================
testnet_1      | (0) 0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d
testnet_1      | (1) 0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1
testnet_1      | (2) 0x6370fd033278c143179d81c5526140625662b8daa446c22ee2d73db3707e620c
testnet_1      | (3) 0x646f1ce2fdad0e6deeeb5c7e8e5543bdde65e86029e2fd9fc169899c440a7913
testnet_1      | (4) 0xadd53f9a7e588d003326d1cbf9e4a43c061aadd9bc938c843a79e7b4fd2ad743
testnet_1      | (5) 0x395df67f0c2d2d9fe1ad08d1bc8b6627011959b79c53d7dd6a3536a33ab8a4fd
testnet_1      | (6) 0xe485d098507f54e7733a205420dfddbe58db035fa577fc294ebd14db90767a52
testnet_1      | (7) 0xa453611d9419d0e56f499079478fd72c37b251a94bfde4d19872c44cf65386e3
testnet_1      | (8) 0x829e924fdf021ba3dbbc4225edfece9aca04b929d6e75613329ca6f1d31c0bb4
testnet_1      | (9) 0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773
testnet_1      | 
testnet_1      | HD Wallet
testnet_1      | ==================
testnet_1      | Mnemonic:      myth like bonus scare over problem client lizard pioneer submit female collect
testnet_1      | Base HD Path:  m/44'/60'/0'/0/{account_index}
testnet_1      | 
testnet_1      | Gas Price
testnet_1      | ==================
testnet_1      | 20000000000
testnet_1      | 
testnet_1      | Gas Limit
testnet_1      | ==================
testnet_1      | 6721975
testnet_1      | 
testnet_1      | Call Gas Limit
testnet_1      | ==================
testnet_1      | 9007199254740991
testnet_1      | 
testnet_1      | Listening on 0.0.0.0:5000
coordinator_1  | 2022/07/30 09:37:42 GoTTY is starting with command: node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json
coordinator_1  | 2022/07/30 09:37:42 Permitting clients to write input to the PTY.
coordinator_1  | 2022/07/30 09:37:42 HTTP server is listening at: http://[::]:1234/
coordinator_1  | 2022/07/30 09:37:42 Alternative URL: http://127.0.0.1:1234/
coordinator_1  | 2022/07/30 09:37:42 Alternative URL: http://172.21.0.3:1234/
wallet_1       | 2022/07/30 09:37:43 GoTTY is starting with command: node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json
wallet_1       | 2022/07/30 09:37:43 Permitting clients to write input to the PTY.
wallet_1       | 2022/07/30 09:37:43 HTTP server is listening at: http://[::]:4321/
wallet_1       | 2022/07/30 09:37:43 Alternative URL: http://127.0.0.1:4321/
wallet_1       | 2022/07/30 09:37:43 Alternative URL: http://172.21.0.4:4321/

Additional context can try with this Cli.dockerfile which is removed node-gyp-build and python2 for build.

sifnoc commented 2 years ago

Alternative way

use built images instead testnet image coordinator/wallet image

edit compose/docker-compose.dev.yml

 services:
   testnet:
-    build:
-      context: ../packages/contracts/
-      dockerfile: ../../dockerfiles/Contract.dockerfile
+    image: sifnoc/zkopru_testnet:main-b50e4c
     ports:
       - "5000:5000"
     command: ganache-cli --db=/data -i 20200406 -p 5000 --deterministic -b 14 --host 0.0.0.0
   coordinator:
-    build:
-      context: ../
-      dockerfile: ./dockerfiles/Cli.dockerfile
+    image: sifnoc/zkopru_node:main-b50e4c
     ports:
       - "8888:8888"
       - "1234:1234"
@@ -23,9 +19,7 @@ services:
       - '../packages:/proj/packages'
     command: sh -c "sleep 5s && gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json"
   wallet:
-    build:
-      context: ../
-      dockerfile: ./dockerfiles/Cli.dockerfile
+    image: sifnoc/zkopru_node:main-b50e4c

or you can get docker-compose.dev.yml

yarn develop will work with this compose file and images

KimiWu123 commented 2 years ago

it's working after applied the pre-built image and edited compose/docker-compose.dev.yml file