Based on CentOS 7 contains a Meteor and NodeJS as a full JavaScript Runtime and App Platform.
10K+
Based on Offical CentOS image from centos:centos7
This Dockerfile stands for a JavaScript Runtime and App Platform where you can develop decentralized applications (Dapps) bundled as single html file connected to an running ethereum node with JavaScript web3 API communicating internally via JSON RPC API.
Pull from dockerhub:
docker pull blakeberg/meteor-nodejs
or copy the sources to your docker host.
docker build --force-rm -t blakeberg/meteor-nodejs .
You can choose to run this container with or without a link to an Ethereum client geth.
docker run -d -h meteor --name meteor -p 10022:22 -p 3000:3000 blakeberg/meteor-nodejs
Container blakeberg/ssh:geth-node exists and is running.
docker run -d -h meteor --name meteor -p 10022:22 -p 3000:3000 --link=geth:geth blakeberg/meteor-nodejs
You will need this link for developing decentralized applications with Ethereum.
If you are connected to this container you can connect to linked container geth too.
If you us boot2docker you shoud add to your /etc/hosts under Windows or Mac OS X the IP and host name of the boot2docker VM
192.168.99.100 meteor(IP to verify)
If you have an issue with cross origin requests you can allow all domains with parameter
--rpccorsdomain "*"and if you can't connect to geth node you can allow all adresses with parameter--rpcaddr "0.0.0.0". Both parameters can be set with geth command see container geth-node (link below)
Connect with ssh use the port that was just located:
ssh -p 10022 meteor@localhost
From this container you can connect to linked container geth via JSON RPC API:
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://geth:8545
If Ethereum node on geth is running you will get a JSON Response
{"id":67,"jsonrpc":"2.0","result":"Geth/v1.3.5/linux/go1.5.1"}
Meteor is a full stack JavaScript App Platform used for creating Apps and Dapps (in case of Blockchain / Ethereum).
Create a new dummy-app within a running container.
meteor create --release 1.2.1 dummy-app (first meteor is installing)cd dummy-appnohup meteor &http://meteor:3000For a more sophisticated example complete the todo app! (link below)
A Dapp contains one or more contracts and a graphical user interface (UI) to handle it. There are some packages for Meteor includig UI you can simply use for that purpose.
Create a new dummy-dapp within a running container. Approve that container blakeberg/ssh:geth-node exists, is linked and its Ethereum client is running.
meteor create --release 1.2.1 dummy-dapp (first meteor is not installing if you done the dummy-app before)cd dummy-dappmeteor add ethereum:web3meteor add ethereum:toolsmeteor add ethereum:elementsmeteor add ethereum:dapp-styles needs also meteor add lessmeteor add ethereum:accountsmeteor add ethereum:blocks@import '{ethereum:dapp-styles}/dapp-styles.less'; to dummy-dapp.cssmv dummy-dapp.css dummy-dapp.lessnohup meteor &http://meteor:3000 (you can only run one meteor instance on that port)This example is included in this container and show at least on use case for each Meteor package for Ethereum. Approve that container blakeberg/ssh:geth-node exists, is linked and its Ethereum client is running.
cp ~/dummy-dapp.* .http://meteor:3000 (should updated immediately)You see see the result "Hello World!" from sample contact "Greeter"
greeter.greet()as example in container geth-node (link below)
With Meteor Build Client you can bundle the client part of a Meteor app with a simple index.html and javascript (and maybe css and images), so it can be hosted on any server or even loaded via the file:// protocol.
Note that the Build Client could not executed successful for Meteor 1.3 projects so that is the reason why there built with option
--release 1.2.1
There is no need for centralized server!
cd dummy-appmeteor-build-client ../bundled-dummy-app -p ""cd ../bundled-dummy-app and see (there is only a html and js file)cd ~/dummy-dappmeteor-build-client ../bundled-dummy-dapp -p ""cd ../bundled-dummy-dapp and see (there is an additional css file and packages folder with images inside)See bundled (d)apps examples:
You can download these files and run via the file:// protocol. The dapp need a running geth-node (link below)
NodeJS is a JavaScript Runtime Environment with Package Manager NPM which installed the Packages solc, web3 and also meteor-build-client described before. Approve that container blakeberg/ssh:geth-node exists, is linked and its Ethereum client is running.
You can also compile contracts with solc from NodeJS as a javascript console type node.
Load solc module:
var solc = require('solc');
solc.version();
Compile contract greeter:
var greeter = solc.compile("contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }");
greeter.contracts.greeter.gasEstimates;
greeter.contracts.mortal.gasEstimates;
You can also execute JavaScript with web3.js from NodeJS as a javascript console type node.
Load web3 module and connect to Ethereum client:
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://geth:8545'));
Get account information:
var coinbase = web3.eth.coinbase;
coinbase;
web3.eth.getBalance(coinbase);
Call contract greeter (as in dapp example above):
var abi = [{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"type":"constructor"}];
var greeter = web3.eth.contract(abi).at("0x0608616212f0356c3d4c7c7b1c317151646164e1");
greeter.greet();
Content type
Image
Digest
Size
353.4 MB
Last updated
about 9 years ago
docker pull blakeberg/meteor-nodejs