cmd/puppeth: simplifications and pre-built docker images

This commit is contained in:
Péter Szilágyi 2017-10-27 14:36:49 +03:00
parent 80be5e5463
commit ffc12f63ec
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
13 changed files with 116 additions and 165 deletions

View File

@ -31,21 +31,9 @@ import (
// ethstatsDockerfile is the Dockerfile required to build an ethstats backend
// and associated monitoring site.
var ethstatsDockerfile = `
FROM mhart/alpine-node:latest
RUN \
apk add --update git && \
git clone --depth=1 https://github.com/puppeth/eth-netstats && \
apk del git && rm -rf /var/cache/apk/* && \
\
cd /eth-netstats && npm install && npm install -g grunt-cli && grunt
WORKDIR /eth-netstats
EXPOSE 3000
FROM puppeth/ethstats:latest
RUN echo 'module.exports = {trusted: [{{.Trusted}}], banned: [{{.Banned}}], reserved: ["yournode"]};' > lib/utils/config.js
CMD ["npm", "start"]
`
// ethstatsComposefile is the docker-compose.yml file required to deploy and

View File

@ -30,31 +30,16 @@ import (
// explorerDockerfile is the Dockerfile required to run a block explorer.
var explorerDockerfile = `
FROM parity/parity:stable
RUN \
apt-get update && apt-get install -y curl git npm make g++ --no-install-recommends && \
npm install -g n pm2 && n stable
RUN \
git clone --depth=1 https://github.com/puppeth/eth-net-intelligence-api && \
cd eth-net-intelligence-api && npm install
RUN \
git clone --depth=1 https://github.com/puppeth/etherchain-light --recursive && \
cd etherchain-light && npm install && mv config.js.example config.js && \
sed -i '/this.bootstrapUrl/c\ this.bootstrapUrl = "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css";' config.js
FROM puppeth/explorer:latest
ADD ethstats.json /ethstats.json
ADD chain.json /chain.json
RUN \
echo '(cd eth-net-intelligence-api && pm2 start /ethstats.json)' > explorer.sh && \
echo '(cd etherchain-light && npm start &)' >> explorer.sh && \
echo '(cd ../eth-net-intelligence-api && pm2 start /ethstats.json)' > explorer.sh && \
echo '(cd ../etherchain-light && npm start &)' >> explorer.sh && \
echo '/parity/parity --chain=/chain.json --port={{.NodePort}} --tracing=on --fat-db=on --pruning=archive' >> explorer.sh
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "explorer.sh"]
`

View File

@ -33,27 +33,14 @@ import (
// faucetDockerfile is the Dockerfile required to build an faucet container to
// grant crypto tokens based on GitHub authentications.
var faucetDockerfile = `
FROM alpine:latest
RUN mkdir /go
ENV GOPATH /go
RUN \
apk add --update git go make gcc musl-dev ca-certificates linux-headers && \
mkdir -p $GOPATH/src/github.com/ethereum && \
(cd $GOPATH/src/github.com/ethereum && git clone --depth=1 https://github.com/ethereum/go-ethereum) && \
go build -v github.com/ethereum/go-ethereum/cmd/faucet && \
apk del git go make gcc musl-dev linux-headers && \
rm -rf $GOPATH && rm -rf /var/cache/apk/*
FROM puppeth/faucet:latest
ADD genesis.json /genesis.json
ADD account.json /account.json
ADD account.pass /account.pass
EXPOSE 8080
CMD [ \
"/faucet", "--genesis", "/genesis.json", "--network", "{{.NetworkID}}", "--bootnodes", "{{.Bootnodes}}", "--ethstats", "{{.Ethstats}}", "--ethport", "{{.EthPort}}", \
ENTRYPOINT [ \
"faucet", "--genesis", "/genesis.json", "--network", "{{.NetworkID}}", "--bootnodes", "{{.Bootnodes}}", "--ethstats", "{{.Ethstats}}", "--ethport", "{{.EthPort}}", \
"--faucet.name", "{{.FaucetName}}", "--faucet.amount", "{{.FaucetAmount}}", "--faucet.minutes", "{{.FaucetMinutes}}", "--faucet.tiers", "{{.FaucetTiers}}", \
{{if .GitHubUser}}"--github.user", "{{.GitHubUser}}", "--github.token", "{{.GitHubToken}}", {{end}}"--account.json", "/account.json", "--account.pass", "/account.pass" \
{{if .CaptchaToken}}, "--captcha.token", "{{.CaptchaToken}}", "--captcha.secret", "{{.CaptchaSecret}}"{{end}}{{if .NoAuth}}, "--noauth"{{end}} \

View File

@ -30,61 +30,7 @@ import (
// walletDockerfile is the Dockerfile required to run a web wallet.
var walletDockerfile = `
FROM ethereum/client-go:latest
RUN \
apk add --update git python make g++ libnotify nodejs-npm && \
npm install -g gulp-cli
RUN \
git clone --depth=1 https://github.com/kvhnuke/etherwallet.git && \
(cd etherwallet && npm install)
WORKDIR etherwallet
RUN \
echo '"use strict";' > app/scripts/nodes.js && \
echo 'var nodes = function() {}' >> app/scripts/nodes.js && \
echo 'nodes.customNode = require("./nodeHelpers/customNode");' >> app/scripts/nodes.js && \
echo 'nodes.nodeTypes = {' >> app/scripts/nodes.js && \
echo ' {{.Network}}: "{{.Denom}} ETH",' >> app/scripts/nodes.js && \
echo ' Custom: "CUSTOM ETH"' >> app/scripts/nodes.js && \
echo '};' >> app/scripts/nodes.js && \
echo 'nodes.ensNodeTypes = [];' >> app/scripts/nodes.js && \
echo 'nodes.customNodeObj = {' >> app/scripts/nodes.js && \
echo ' "name": "CUS",' >> app/scripts/nodes.js && \
echo ' "type": nodes.nodeTypes.Custom,' >> app/scripts/nodes.js && \
echo ' "eip155": false,' >> app/scripts/nodes.js && \
echo ' "chainId": "",' >> app/scripts/nodes.js && \
echo ' "tokenList": [],' >> app/scripts/nodes.js && \
echo ' "abiList": [],' >> app/scripts/nodes.js && \
echo ' "service": "Custom",' >> app/scripts/nodes.js && \
echo ' "lib": null' >> app/scripts/nodes.js && \
echo '}' >> app/scripts/nodes.js && \
echo 'nodes.nodeList = {' >> app/scripts/nodes.js && \
echo ' "eth_mew": {' >> app/scripts/nodes.js && \
echo ' "name": "{{.Network}}",' >> app/scripts/nodes.js && \
echo ' "type": nodes.nodeTypes.{{.Network}},' >> app/scripts/nodes.js && \
echo ' "eip155": true,' >> app/scripts/nodes.js && \
echo ' "chainId": {{.NetworkID}},' >> app/scripts/nodes.js && \
echo ' "tokenList": [],' >> app/scripts/nodes.js && \
echo ' "abiList": [],' >> app/scripts/nodes.js && \
echo ' "service": "Go Ethereum",' >> app/scripts/nodes.js && \
echo ' "lib": new nodes.customNode("http://{{.Host}}:{{.RPCPort}}", "")' >> app/scripts/nodes.js && \
echo ' }' >> app/scripts/nodes.js && \
echo '};' >> app/scripts/nodes.js && \
echo 'nodes.ethPrice = require("./nodeHelpers/ethPrice");' >> app/scripts/nodes.js && \
echo 'module.exports = nodes;' >> app/scripts/nodes.js
RUN rm -rf dist && gulp prep && npm run dist
RUN \
npm install connect serve-static && \
\
echo 'var connect = require("connect");' > server.js && \
echo 'var serveStatic = require("serve-static");' >> server.js && \
echo 'connect().use(serveStatic("/etherwallet/dist")).listen(80, function(){' >> server.js && \
echo ' console.log("Server running on 80...");' >> server.js && \
echo '});' >> server.js
FROM puppeth/wallet:latest
ADD genesis.json /genesis.json
@ -93,7 +39,12 @@ RUN \
echo 'geth --cache 512 init /genesis.json' >> wallet.sh && \
echo $'geth --networkid {{.NetworkID}} --port {{.NodePort}} --bootnodes {{.Bootnodes}} --ethstats \'{{.Ethstats}}\' --cache=512 --rpc --rpcaddr=0.0.0.0 --rpccorsdomain "*"' >> wallet.sh
EXPOSE 80 8545
RUN \
sed -i 's/PuppethNetworkID/{{.NetworkID}}/g' dist/js/etherwallet-master.js && \
sed -i 's/PuppethNetwork/{{.Network}}/g' dist/js/etherwallet-master.js && \
sed -i 's/PuppethDenom/{{.Denom}}/g' dist/js/etherwallet-master.js && \
sed -i 's/PuppethHost/{{.Host}}/g' dist/js/etherwallet-master.js && \
sed -i 's/PuppethRPCPort/{{.RPCPort}}/g' dist/js/etherwallet-master.js
ENTRYPOINT ["/bin/sh", "wallet.sh"]
`

View File

@ -116,6 +116,7 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
keycheck := func(hostname string, remote net.Addr, key ssh.PublicKey) error {
// If no public key is known for SSH, ask the user to confirm
if pubkey == nil {
fmt.Println()
fmt.Printf("The authenticity of host '%s (%s)' can't be established.\n", hostname, remote)
fmt.Printf("SSH key fingerprint is %s [MD5]\n", ssh.FingerprintLegacyMD5(key))
fmt.Printf("Are you sure you want to continue connecting (yes/no)? ")

View File

@ -33,12 +33,15 @@ func (w *wizard) deployDashboard() {
client := w.servers[server]
// Retrieve any active dashboard configurations from the server
existed := true
infos, err := checkDashboard(client, w.network)
if err != nil {
infos = &dashboardInfos{
port: 80,
host: client.server,
}
existed = false
}
// Figure out which port to listen on
fmt.Println()
@ -138,10 +141,12 @@ func (w *wizard) deployDashboard() {
infos.trusted = w.readDefaultString("y") == "y"
}
// Try to deploy the dashboard container on the host
fmt.Println()
fmt.Printf("Should the dashboard be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the dashboard be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployDashboard(client, w.network, &w.conf, infos, nocache); err != nil {
log.Error("Failed to deploy dashboard container", "err", err)
if len(out) > 0 {

View File

@ -34,6 +34,8 @@ func (w *wizard) deployEthstats() {
client := w.servers[server]
// Retrieve any active ethstats configurations from the server
existed := true
infos, err := checkEthstats(client, w.network)
if err != nil {
infos = &ethstatsInfos{
@ -41,6 +43,7 @@ func (w *wizard) deployEthstats() {
host: client.server,
secret: "",
}
existed = false
}
// Figure out which port to listen on
fmt.Println()
@ -62,46 +65,50 @@ func (w *wizard) deployEthstats() {
infos.secret = w.readDefaultString(infos.secret)
}
// Gather any blacklists to ban from reporting
fmt.Println()
fmt.Printf("Keep existing IP %v blacklist (y/n)? (default = yes)\n", infos.banned)
if w.readDefaultString("y") != "y" {
// The user might want to clear the entire list, although generally probably not
if existed {
fmt.Println()
fmt.Printf("Clear out blacklist and start over (y/n)? (default = no)\n")
if w.readDefaultString("n") != "n" {
infos.banned = nil
}
// Offer the user to explicitly add/remove certain IP addresses
fmt.Println()
fmt.Println("Which additional IP addresses should be blacklisted?")
for {
if ip := w.readIPAddress(); ip != "" {
infos.banned = append(infos.banned, ip)
continue
fmt.Printf("Keep existing IP %v blacklist (y/n)? (default = yes)\n", infos.banned)
if w.readDefaultString("y") != "y" {
// The user might want to clear the entire list, although generally probably not
fmt.Println()
fmt.Printf("Clear out blacklist and start over (y/n)? (default = no)\n")
if w.readDefaultString("n") != "n" {
infos.banned = nil
}
break
}
fmt.Println()
fmt.Println("Which IP addresses should not be blacklisted?")
for {
if ip := w.readIPAddress(); ip != "" {
for i, addr := range infos.banned {
if ip == addr {
infos.banned = append(infos.banned[:i], infos.banned[i+1:]...)
break
}
// Offer the user to explicitly add/remove certain IP addresses
fmt.Println()
fmt.Println("Which additional IP addresses should be blacklisted?")
for {
if ip := w.readIPAddress(); ip != "" {
infos.banned = append(infos.banned, ip)
continue
}
continue
break
}
break
fmt.Println()
fmt.Println("Which IP addresses should not be blacklisted?")
for {
if ip := w.readIPAddress(); ip != "" {
for i, addr := range infos.banned {
if ip == addr {
infos.banned = append(infos.banned[:i], infos.banned[i+1:]...)
break
}
}
continue
}
break
}
sort.Strings(infos.banned)
}
sort.Strings(infos.banned)
}
// Try to deploy the ethstats server on the host
fmt.Println()
fmt.Printf("Should the ethstats be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the ethstats be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
trusted := make([]string, 0, len(w.servers))
for _, client := range w.servers {
if client != nil {

View File

@ -47,9 +47,14 @@ func (w *wizard) deployExplorer() {
client := w.servers[server]
// Retrieve any active node configurations from the server
existed := true
infos, err := checkExplorer(client, w.network)
if err != nil {
infos = &explorerInfos{nodePort: 30303, webPort: 80, webHost: client.server}
infos = &explorerInfos{
nodePort: 30303, webPort: 80, webHost: client.server,
}
existed = false
}
chainspec, err := newParityChainSpec(w.network, w.conf.Genesis, w.conf.bootFull)
if err != nil {
@ -92,10 +97,12 @@ func (w *wizard) deployExplorer() {
infos.ethstats = w.readDefaultString(infos.ethstats) + ":" + w.conf.ethstats
}
// Try to deploy the explorer on the host
fmt.Println()
fmt.Printf("Should the explorer be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the explorer be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployExplorer(client, w.network, chain, infos, nocache); err != nil {
log.Error("Failed to deploy explorer container", "err", err)
if len(out) > 0 {

View File

@ -36,6 +36,8 @@ func (w *wizard) deployFaucet() {
client := w.servers[server]
// Retrieve any active faucet configurations from the server
existed := true
infos, err := checkFaucet(client, w.network)
if err != nil {
infos = &faucetInfos{
@ -46,6 +48,7 @@ func (w *wizard) deployFaucet() {
minutes: 1440,
tiers: 3,
}
existed = false
}
infos.node.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.node.network = w.conf.Genesis.Config.ChainId.Int64()
@ -206,10 +209,12 @@ func (w *wizard) deployFaucet() {
infos.noauth = w.readDefaultString(noauth) != "n"
// Try to deploy the faucet server on the host
fmt.Println()
fmt.Printf("Should the faucet be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the faucet be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployFaucet(client, w.network, w.conf.bootLight, infos, nocache); err != nil {
log.Error("Failed to deploy faucet container", "err", err)
if len(out) > 0 {

View File

@ -175,7 +175,7 @@ func (w *wizard) deployComponent() {
fmt.Println(" 2. Bootnode - Entry point of the network")
fmt.Println(" 3. Sealer - Full node minting new blocks")
fmt.Println(" 4. Explorer - Chain analysis webservice (ethash only)")
fmt.Println(" 5. Wallet - Browser wallet for quick sends (todo)")
fmt.Println(" 5. Wallet - Browser wallet for quick sends")
fmt.Println(" 6. Faucet - Crypto faucet to give away funds")
fmt.Println(" 7. Dashboard - Website listing above web-services")

View File

@ -29,7 +29,8 @@ import (
//
// If the user elects not to use a reverse proxy, an empty hostname is returned!
func (w *wizard) ensureVirtualHost(client *sshClient, port int, def string) (string, error) {
if proxy, _ := checkNginx(client, w.network); proxy != nil {
proxy, _ := checkNginx(client, w.network)
if proxy != nil {
// Reverse proxy is running, if ports match, we need a virtual host
if proxy.port == port {
fmt.Println()
@ -41,10 +42,12 @@ func (w *wizard) ensureVirtualHost(client *sshClient, port int, def string) (str
fmt.Println()
fmt.Println("Allow sharing the port with other services (y/n)? (default = yes)")
if w.readDefaultString("y") == "y" {
fmt.Println()
fmt.Printf("Should the reverse-proxy be rebuilt from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if proxy != nil {
fmt.Println()
fmt.Printf("Should the reverse-proxy be rebuilt from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployNginx(client, w.network, port, nocache); err != nil {
log.Error("Failed to deploy reverse-proxy", "err", err)
if len(out) > 0 {

View File

@ -45,6 +45,8 @@ func (w *wizard) deployNode(boot bool) {
client := w.servers[server]
// Retrieve any active node configurations from the server
existed := true
infos, err := checkNode(client, w.network, boot)
if err != nil {
if boot {
@ -52,6 +54,7 @@ func (w *wizard) deployNode(boot bool) {
} else {
infos = &nodeInfos{portFull: 30303, peersTotal: 50, peersLight: 0, gasTarget: 4.7, gasPrice: 18}
}
existed = false
}
infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.network = w.conf.Genesis.Config.ChainId.Int64()
@ -155,10 +158,12 @@ func (w *wizard) deployNode(boot bool) {
infos.gasPrice = w.readDefaultFloat(infos.gasPrice)
}
// Try to deploy the full node on the host
fmt.Println()
fmt.Printf("Should the node be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the node be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployNode(client, w.network, w.conf.bootFull, w.conf.bootLight, infos, nocache); err != nil {
log.Error("Failed to deploy Ethereum node container", "err", err)
if len(out) > 0 {

View File

@ -43,9 +43,14 @@ func (w *wizard) deployWallet() {
client := w.servers[server]
// Retrieve any active node configurations from the server
existed := true
infos, err := checkWallet(client, w.network)
if err != nil {
infos = &walletInfos{nodePort: 30303, rpcPort: 8545, webPort: 80, webHost: client.server}
infos = &walletInfos{
nodePort: 30303, rpcPort: 8545, webPort: 80, webHost: client.server,
}
existed = false
}
infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
infos.network = w.conf.Genesis.Config.ChainId.Int64()
@ -75,7 +80,7 @@ func (w *wizard) deployWallet() {
infos.nodePort = w.readDefaultInt(infos.nodePort)
fmt.Println()
fmt.Printf("Which TCP/UDP port should the backing RPC API listen on? (default = %d)\n", infos.rpcPort)
fmt.Printf("Which port should the backing RPC API listen on? (default = %d)\n", infos.rpcPort)
infos.rpcPort = w.readDefaultInt(infos.rpcPort)
// Set a proper name to report on the stats page
@ -88,10 +93,12 @@ func (w *wizard) deployWallet() {
infos.ethstats = w.readDefaultString(infos.ethstats) + ":" + w.conf.ethstats
}
// Try to deploy the wallet on the host
fmt.Println()
fmt.Printf("Should the wallet be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
nocache := false
if existed {
fmt.Println()
fmt.Printf("Should the wallet be built from scratch (y/n)? (default = no)\n")
nocache = w.readDefaultString("n") != "n"
}
if out, err := deployWallet(client, w.network, w.conf.bootFull, infos, nocache); err != nil {
log.Error("Failed to deploy wallet container", "err", err)
if len(out) > 0 {