switched configuration process to yeoman generator inside a minimal docker image

This commit is contained in:
jash
2018-10-06 14:40:27 +02:00
committed by kexkey
parent acb777db90
commit 91aab75e39
13 changed files with 222 additions and 65 deletions

View File

@@ -1,3 +1,6 @@
SatoshiPortal
data
script
generator-cyphernode/node_modules
generator-cyphernode/package-lock
generator-cyphernode/__tests__

View File

@@ -1,13 +1,25 @@
FROM alpine
FROM node:alpine
RUN apk add --update --no-cache \
curl \
dialog
RUN apk add --update bash && rm -rf /var/cache/apk/*
RUN adduser -D -h /yo yo yo
RUN chown -R yo:yo /usr/local/lib/node_modules /usr/local/bin
RUN mkdir /volume /script /data
USER yo
RUN npm install -g yo
COPY generator-cyphernode /yo
WORKDIR /yo/generator-cyphernode
RUN npm link
WORKDIR /script
USER root
RUN mkdir -p /yo/.config/insight-nodejs
ENV TRACING=1
# prevent "do you want to send stats"-questions for temporary yo installation
COPY insight-yo.json /yo/.config/insight-nodejs/insight-yo.json
RUN chown -R yo:yo /yo/.config
# run in user space
USER yo
WORKDIR /yo
CMD ["yo","cyphernode"]
CMD ["./configure.sh"]

View File

@@ -1,7 +0,0 @@
#!/bin/sh
# TODO: config entry for persistent volume of bitcoind
dialog --colors --textbox trace.sh 40 80

View File

@@ -1,15 +0,0 @@
#!/bin/sh
trace()
{
if [ -n "${TRACING}" ]; then
echo "[$(date +%Y-%m-%dT%H:%M:%S%z)] ${1}" > /dev/stderr
fi
}
trace_rc()
{
if [ -n "${TRACING}" ]; then
echo "[$(date +%Y-%m-%dT%H:%M:%S%z)] Last return code: ${1}" > /dev/stderr
fi
}

View File

@@ -1,11 +0,0 @@
# testnet
testnet=1
#lnd opts
txindex=1
zmqpubrawblock=tcp://0.0.0.0:18501
zmqpubrawtx=tcp://0.0.0.0:18502
# general opts
rpcuser=%RPCUSER%
rpcpassword=%RPCPASSWORD%

0
install/data/.gitkeep Normal file
View File

View File

@@ -0,0 +1,2 @@
node_modules
coverage

View File

@@ -0,0 +1,113 @@
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const fs = require('fs');
const wrap = require('wordwrap')(86);
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);
this.props = {
name: 'supercollider-project',
type: 'simple',
description: ''
};
}
/*
prompting() {
const prompts = [
{
type: 'confirm',
name: 'someAnswer',
message: 'Would you like to enable this option?',
default: true
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
*/
// fountainPrompting() {
prompting() {
const splash = fs.readFileSync(this.templatePath('splash.txt'));
this.log(splash.toString());
var prompts = [
{
// https://github.com/SBoudrias/Inquirer.js#question
// input, confirm, list, rawlist, expand, checkbox, password, editor
type: 'checkbox',
name: 'features',
message: wrap('What features do you want to add to your cyphernode?')+'\n',
choices: [
{
name: 'Bitcoin full node',
value: 'bitcoin'
},
{
name: 'Lightning node',
value: 'lightning'
},
{
name: 'Open timestamps server',
value: 'ots'
}
]
},
{
when: function(answers) {
return answers.features &&
answers.features.indexOf( 'bitcoin' ) != -1;
},
type: 'confirm',
default: false,
name: 'lightning_implementation',
message: wrap('Run bitcoin node in prune mode?')+'\n',
},
{
when: function(answers) {
return answers.features &&
answers.features.indexOf( 'lightning' ) != -1;
},
type: 'list',
name: 'lightning_implementation',
message: wrap('What lightning implementation do you want to use?')+'\n',
choices: [
{
name: 'C-lightning',
value: 'c-lightning'
},
{
name: 'LND',
value: 'lnd'
}
]
}
];
return this.prompt(prompts).then(props => {
this.props = Object.assign(this.props, props);
});
}
writing() {
/*
this.fs.copy(
this.templatePath('dummyfile.txt'),
this.destinationPath('dummyfile.txt')
);
*/
}
install() {
}
};

View File

@@ -0,0 +1,27 @@
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           
                                           

View File

@@ -0,0 +1,29 @@
{
"name": "generator-cyphernode",
"version": "0.0.0",
"description": "",
"homepage": "",
"author": {
"name": "jash",
"email": "jash@schulterklopfer-productions.de",
"url": ""
},
"files": [
"generators"
],
"main": "generators/index.js",
"keywords": [
"cyphernode",
"yeoman-generator"
],
"engines": {
"npm": ">= 4.0.0"
},
"dependencies": {
"chalk": "^2.1.0",
"wordwrap": "^1.0.0",
"yeoman-generator": "^2.0.1"
},
"repository": "git@github.com:schulterklopfer/cyphernode.git",
"license": "MIT"
}

3
install/insight-yo.json Normal file
View File

@@ -0,0 +1,3 @@
{
"optOut": true
}

View File

@@ -8,13 +8,11 @@
# commands not needed for runtime
cyphernodeconf_configure() {
PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
DATA_PATH=$PWD/../data
SCRIPT_PATH=$PWD/../$1/script
VOLUME_PATH=/tmp
docker run -v $VOLUME_PATH:/volume \
-v $DATA_PATH:/data \
-v $SCRIPT_PATH:/script\
local current_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
local data_path=$current_path/../data
local docker_image="cyphernodeconf:latest"
docker run -v $data_path:/data \
--log-driver=none\
--rm -it cyphernodeconf:latest
--rm -it $docker_image
}

View File

@@ -3,22 +3,25 @@
. ./trace.sh
. ./docker.sh
. ./cyphernodeconf.sh
. ./config.sh
config_file=$1
trace "Updating SatoshiPortal dockers"
git submodule update --recursive --remote
#git submodule update --recursive --remote
#
## build SatoshiPortal images
#local arch=x86_64
#build_docker_image ../SatoshiPortal/dockers/$arch/bitcoin-core btcnode
#build_docker_image ../SatoshiPortal/dockers/$arch/LN/c-lightning clnimg
#
## build cyphernode images
#build_docker_image ../../cron_docker/ proxycronimg
#build_docker_image ../../proxy_docker/ btcproxyimg
#build_docker_image ../../pycoin_docker/ pycoinimg
#
## build setup docker image
build_docker_image ../ cyphernodeconf && clear && echo "Thinking..."
# build SatoshiPortal images
arch=x86_64
build_docker_image ../SatoshiPortal/dockers/$arch/bitcoin-core btcnode
build_docker_image ../SatoshiPortal/dockers/$arch/LN/c-lightning clnimg
# build cyphernode images
build_docker_image ../../cron_docker/ proxycronimg
build_docker_image ../../proxy_docker/ btcproxyimg
build_docker_image ../../pycoin_docker/ pycoinimg
# build setup docker image
build_docker_image ../ cyphernodeconf
# configure bitcoind
cyphernodeconf_configure bitcoind
# configure features of cyphernode
cyphernodeconf_configure