docker-dapp

所属分类:区块链开发
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2018-04-06 19:15:29
上 传 者sh-1993
说明:  使用docker创建DApp(去中心化应用程序),
(Create a DApp (Decentralized Application) with docker,)

文件列表:
docker/ (0, 2018-04-06)
docker/docker-compose.yml (388, 2018-04-06)
docker/docker-truffleapp/ (0, 2018-04-06)
docker/docker-truffleapp/Dockerfile (193, 2018-04-06)
source/ (0, 2018-04-06)
source/.babelrc (25, 2018-04-06)
source/.eslintignore (129, 2018-04-06)
source/.eslintrc (308, 2018-04-06)
source/app/ (0, 2018-04-06)
source/app/index.html (925, 2018-04-06)
source/app/javascripts/ (0, 2018-04-06)
source/app/javascripts/app.js (3638, 2018-04-06)
source/app/stylesheets/ (0, 2018-04-06)
source/app/stylesheets/app.css (566, 2018-04-06)
source/box-img-lg.png (10281, 2018-04-06)
source/box-img-sm.png (5386, 2018-04-06)
source/build/ (0, 2018-04-06)
source/build/app.js (1355724, 2018-04-06)
source/build/contracts/ (0, 2018-04-06)
source/build/contracts/ConvertLib.json (16039, 2018-04-06)
source/build/contracts/MetaCoin.json (98676, 2018-04-06)
source/build/contracts/Migrations.json (52457, 2018-04-06)
source/build/index.html (925, 2018-04-06)
source/contracts/ (0, 2018-04-06)
source/contracts/ConvertLib.sol (197, 2018-04-06)
source/contracts/MetaCoin.sol (992, 2018-04-06)
source/contracts/Migrations.sol (515, 2018-04-06)
source/migrations/ (0, 2018-04-06)
source/migrations/1_initial_migration.js (129, 2018-04-06)
source/migrations/2_deploy_contracts.js (249, 2018-04-06)
source/package-lock.json (329519, 2018-04-06)
source/package.json (1176, 2018-04-06)
source/test/ (0, 2018-04-06)
source/test/TestMetacoin.sol (630, 2018-04-06)
source/test/metacoin.js (2462, 2018-04-06)
source/truffle.js (263, 2018-04-06)
source/webpack.config.js (801, 2018-04-06)

# Create a DApp (Decentralized Application) with docker This is a sample project for creating a DApp (Decentralized application) with docker * [Prerequisites](https://github.com/aas2015001/docker-dapp/blob/master/#Prerequisites) * [Instructions](https://github.com/aas2015001/docker-dapp/blob/master/#Instructions) ## Prerequisites * Docker Toolbox for Windows or Docker ## Instructions * Create a new directory and CD into ```docker mkdir -p docker-dapp/docker && cd docker-dapp/docker ``` * Create a docker-compose.yml file ```docker version: '3' services: ganachecli: image: trufflesuite/ganache-cli:latest command: bash -c "ganache-cli -h 0.0.0.0" ports: - 8545:8545 truffleapp: build: context: ./docker-truffleapp command: bash stdin_open: true tty: true ports: - 8080:8080 volumes: - ../source/:/source ``` * Create a Dockerfile for a Truffleapp into docker-truffleapp directory ```docker # Node image FROM node:latest # Create code directory RUN mkdir /source # Set working directory WORKDIR /source # Install Truffle RUN npm install -g truffle && npm config set bin-links false ``` * Run a docker-composer command to start containers ```docker docker-compose -f docker-compose.yml up -d ``` * Install metamask chrome extension and check if ethereum client (Ganache) works! 1. [Metamask chrome extension](https://github.com/aas2015001/docker-dapp/blob/master/https://metamask.io/) 2. Open Metamask and configure custom private network (http://dockerhost:8545) 3. Gets a list accounts from ganache container ```docker docker logs -f docker_ganachecli_1 ``` 3. Import an account with the private key retrevie from ganache container logs * Create a Truffle application ```docker docker exec -it docker_truffleapp_1 bash truffle unbox webpack truffle compile truffle migrate ``` * Manual correction - Update the truffle.js file as mentioned below (host and port are changed) ```docker // Allows us to use ES6 in our migrations and tests. require('babel-register') module.exports = { networks: { development: { host: 'ganachecli', port: 8545, network_id: '*' // Match any network id } } } ``` * Recompile the Truffle application ```docker truffle compile truffle migrate ``` * Manual correction - Update the build and dev scripts in package.json file as mentioned below ``` "build": "./node_modules/webpack/bin/webpack.js", "dev": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --host 0.0.0.0 --public dockerhost " ``` * Manual correction - Update the Web3 HttpProvider in app.js file as mentioned below ``` window.web3 = new Web3(new Web3.providers.HttpProvider("http://dockerhost:8545")); ``` * Build and Run the truffle application ``` npm run build npm run dev ``` * Open a webpage @ http://dockerhost:8080/

近期下载者

相关文件


收藏者