Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
implement config using confd
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikhofstadt committed May 2, 2018
1 parent 77e3dac commit c8b49ff
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 72 deletions.
6 changes: 4 additions & 2 deletions examples/betanet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2"
services:

lisk:
image: lisk/betanet:next
image: lisk/betanet:1.0.0-beta.6
volumes:
- lisk-logs:/home/lisk/lisk/logs/
ports:
Expand All @@ -14,7 +14,9 @@ services:
- db
command: ["/home/lisk/wait-for-it.sh", "db:5432", "--", "/home/lisk/run.sh"]
environment:
- LISK_CONFIG_DB_DATABASE=lisk_beta
- LISK_DB_NAME=lisk_beta
- LISK_DB_HOST=db
- LISK_REDIS_HOST=redis
restart: on-failure

db:
Expand Down
36 changes: 36 additions & 0 deletions images/Dockerfile.betanet
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM lisk/base

ARG network=betanet
ARG version
ARG minVersion

# download and verify image
RUN curl --fail https://downloads.lisk.io/lisk/beta/lisk-Linux-x86_64.tar.gz --output betanet-lisk-Linux-x86_64.tar.gz && \
curl --fail https://downloads.lisk.io/lisk/beta/lisk-Linux-x86_64.tar.gz.SHA256 --output betanet-lisk-Linux-x86_64.tar.gz.SHA256 && \
sed -i 's/ \(lisk-Linux-x86_64.tar.gz\)/ betanet-\1/' betanet-lisk-Linux-x86_64.tar.gz.SHA256 && \
sha256sum -c betanet-lisk-Linux-x86_64.tar.gz.SHA256 && \
rm betanet-lisk-Linux-x86_64.tar.gz.SHA256

# unpack the binaries
RUN tar -xzf betanet-lisk-Linux-x86_64.tar.gz && \
rm betanet-lisk-Linux-x86_64.tar.gz && \
chown lisk:lisk --recursive /home/lisk/lisk-Linux-x86_64

ENV VERSION ${version}
ENV MIN_VERSION ${minVersion}

# add seed nodes
ENV LISK_PEERS_LIST_1 "94.237.41.99:5001"
ENV LISK_PEERS_LIST_2 "209.50.52.217:5001"
ENV LISK_PEERS_LIST_3 "94.237.26.150:5001"
ENV LISK_PEERS_LIST_4 "83.136.249.102:5001"
ENV LISK_PEERS_LIST_5 "94.237.65.179:5001"

# set nethash
ENV LISK_NETHASH "ef3844327d1fd0fc5785291806150c937797bdb34a748c9cd932b7e859e9ca0c"
ENV LISK_WSPORT "5001"
ENV LISK_HTTPPORT "5000"

USER lisk
WORKDIR /home/lisk/lisk-Linux-x86_64
CMD ["/home/lisk/run.sh"]
12 changes: 9 additions & 3 deletions images/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
all: testnet mainnet
.PHONY: all clean testnet
all: base betanet

%:
make -C lisk $@
tag = next

base:
make -C lisk

betanet:
docker build --build-arg network=betanet --tag lisk/betanet:$(version) --build-arg version="$(version)" --build-arg minVersion="$(minversion)" -f Dockerfile.betanet .
18 changes: 8 additions & 10 deletions images/lisk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
FROM ubuntu:16.04

ARG network=testnet

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install --no-install-recommends \
curl sudo unzip wget zip \
jq moreutils && \
curl wget sudo ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN wget https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64 && \
mv confd-0.15.0-linux-amd64 /usr/bin/confd && \
chmod +x /usr/bin/confd

RUN groupadd --gid 1100 lisk && \
useradd lisk --create-home --home-dir /home/lisk --shell /bin/bash --uid 1100 --gid 1100

# the chown flag does not work with tarballs
ADD ${network}-lisk-Linux-x86_64.tar.gz /home/lisk/
RUN chown lisk:lisk --recursive /home/lisk/lisk-Linux-x86_64
COPY --chown=lisk:lisk files/ /
RUN chmod +x /home/lisk/wait-for-it.sh && \
chmod +x /home/lisk/run.sh

USER lisk
WORKDIR /home/lisk/lisk-Linux-x86_64
CMD ["/home/lisk/run.sh"]
WORKDIR /home/lisk
44 changes: 4 additions & 40 deletions images/lisk/Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
.PHONY: all clean testnet
all: testnet mainnet
all: base

tag = next
tag = latest

clean:
rm -f *-lisk-Linux-x86_64.tar.gz*

betanet-lisk-Linux-x86_64.tar.gz:
curl --fail https://downloads.lisk.io/lisk/beta/lisk-Linux-x86_64.tar.gz --output betanet-lisk-Linux-x86_64.tar.gz
curl --fail https://downloads.lisk.io/lisk/beta/lisk-Linux-x86_64.tar.gz.SHA256 --output betanet-lisk-Linux-x86_64.tar.gz.SHA256
sed -i 's/ \(lisk-Linux-x86_64.tar.gz\)/ betanet-\1/' betanet-lisk-Linux-x86_64.tar.gz.SHA256
sha256sum -c betanet-lisk-Linux-x86_64.tar.gz.SHA256

betanet: betanet-lisk-Linux-x86_64.tar.gz
docker build --build-arg network=betanet --tag lisk/betanet:$(tag) .

development-lisk-Linux-x86_64.tar.gz:
curl --fail https://downloads.lisk.io/lisk/development/lisk-Linux-x86_64.tar.gz --output development-lisk-Linux-x86_64.tar.gz
curl --fail https://downloads.lisk.io/lisk/development/lisk-Linux-x86_64.tar.gz.SHA256 --output development-lisk-Linux-x86_64.tar.gz.SHA256
sed -i 's/ \(lisk-Linux-x86_64.tar.gz\)/ development-\1/' development-lisk-Linux-x86_64.tar.gz.SHA256
sha256sum -c development-lisk-Linux-x86_64.tar.gz.SHA256

development: development-lisk-Linux-x86_64.tar.gz
docker build --build-arg network=development --tag lisk/development:$(tag) .

mainnet-lisk-Linux-x86_64.tar.gz:
curl --fail https://downloads.lisk.io/lisk/main/lisk-Linux-x86_64.tar.gz --output mainnet-lisk-Linux-x86_64.tar.gz
curl --fail https://downloads.lisk.io/lisk/main/lisk-Linux-x86_64.tar.gz.SHA256 --output mainnet-lisk-Linux-x86_64.tar.gz.SHA256
sed -i 's/ \(lisk-Linux-x86_64.tar.gz\)/ mainnet-\1/' mainnet-lisk-Linux-x86_64.tar.gz.SHA256
sha256sum -c mainnet-lisk-Linux-x86_64.tar.gz.SHA256

mainnet: mainnet-lisk-Linux-x86_64.tar.gz
docker build --build-arg network=mainnet --tag lisk/mainnet:$(tag) .

testnet-lisk-Linux-x86_64.tar.gz:
curl --fail https://downloads.lisk.io/lisk/test/lisk-Linux-x86_64.tar.gz --output testnet-lisk-Linux-x86_64.tar.gz
curl --fail https://downloads.lisk.io/lisk/test/lisk-Linux-x86_64.tar.gz.SHA256 --output testnet-lisk-Linux-x86_64.tar.gz.SHA256
sed -i 's/ \(lisk-Linux-x86_64.tar.gz\)/ testnet-\1/' testnet-lisk-Linux-x86_64.tar.gz.SHA256
sha256sum -c testnet-lisk-Linux-x86_64.tar.gz.SHA256

testnet: testnet-lisk-Linux-x86_64.tar.gz
docker build --tag lisk/testnet:$(tag) .
base:
docker build --build-arg network=betanet --tag lisk/base:$(tag) .
6 changes: 6 additions & 0 deletions images/lisk/files/etc/confd/conf.d/lisk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[template]
src = "config.json.tmpl"
dest = "/home/lisk/lisk-Linux-x86_64/config.json"
keys = [
"/lisk",
]
104 changes: 104 additions & 0 deletions images/lisk/files/etc/confd/templates/config.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"wsPort": {{getv "/lisk/wsport" "5001"}},
"httpPort": {{getv "/lisk/httpport" "5000"}},
"address": "0.0.0.0",
"version": "{{getenv "VERSION"}}",
"minVersion": "{{getenv "MIN_VERSION"}}",
"fileLogLevel": "{{getv "/lisk/log/filelevel" "info"}}",
"logFileName": "{{getv "/lisk/log/filepath" "logs/lisk.log"}}",
"consoleLogLevel": "{{getv "/lisk/log/consolelevel" "none"}}",
"trustProxy": {{getv "/lisk/trustproxy" "false"}},
"topAccounts": {{getv "/lisk/topaccounts" "false"}},
"cacheEnabled": {{getv "/lisk/cacheenabled" "false"}},
"wsWorkers": {{getv "/lisk/wsworkers" "1"}},
"db": {
"host": "{{getv "/lisk/db/host" "db"}}",
"port": {{getv "/lisk/db/port" "5432"}},
"database": "{{getv "/lisk/db/name" "lisk"}}",
"user": "{{getv "/lisk/db/user" "lisk"}}",
"password": "{{getv "/lisk/db/password" "password"}}",
"min": {{getv "/lisk/db/min" "10"}},
"max": {{getv "/lisk/db/max" "95"}},
"poolIdleTimeout": {{getv "/lisk/db/poolidletimeout" "30000"}},
"reapIntervalMillis": {{getv "/lisk/db/reapintervalms" "1000"}},
"logEvents": ["error"],
"logFileName": "{{getv "/lisk/db/logpath" "logs/lisk_db.log"}}"
},
"redis": {
"host": "{{getv "/lisk/redis/host" "redis"}}",
"port": {{getv "/lisk/redis/port" "6380"}},
"db": {{getv "/lisk/redis/db" "0"}},
"password": {{getv "/lisk/redis/password" "null"}}
},
"api": {
"enabled": {{getv "/lisk/api/enabled" "true"}},
"access": {
"public": {{getv "/lisk/api/public" "false"}},
{{$whiteListEntries := getvs "/lisk/api/whitelist/*"}}"whiteList": [{{range $index, $element := $whiteListEntries}}{{if $index}},{{end}}"{{$element}}"{{end}}]
},
"options": {
"limits": {
"max": {{getv "/lisk/api/limits/max" "0"}},
"delayMs": {{getv "/lisk/api/limits/delayms" "0"}},
"delayAfter": {{getv "/lisk/api/limits/delayafter" "0"}},
"windowMs": {{getv "/lisk/api/limits/windowms" "60000"}}
}
}
},
"peers": {
"enabled": {{getv "/lisk/peers/enabled" "true"}},
"list": [{{range $index, $element := (getvs "/lisk/peers/list/*")}}{{$data := split $element ":"}}{{if $index}},{{end}}
{
"ip": "{{index $data 0}}",
"wsPort": {{index $data 1}}
}{{end}}
],
"access": {
{{$blackListEntries := getvs "/lisk/peers/blacklist/*"}}"blackList": [{{range $index, $element := $blackListEntries}}{{if $index}},{{end}}"{{$element}}"{{end}}]
},
"options": {
"timeout": {{getv "/lisk/peer/timeout" "5000"}}
}
},
"broadcasts": {
"active": {{getv "/lisk/broadcasts/active" "true"}},
"broadcastInterval": {{getv "/lisk/broadcasts/interval" "5000"}},
"broadcastLimit": {{getv "/lisk/broadcasts/limit/broadcast" "20"}},
"parallelLimit": {{getv "/lisk/broadcasts/limit/parallel" "20"}},
"releaseLimit": {{getv "/lisk/broadcasts/limit/release" "25"}},
"relayLimit": {{getv "/lisk/broadcasts/limit/relay" "2"}}
},
"transactions": {
"maxTransactionsPerQueue": {{getv "/lisk/transactions/maxperqueue" "1000"}}
},
"forging": {
"force": {{getv "/lisk/forging/force" "false"}},
"defaultKey": "{{getv "/lisk/forging/defaultkey" ""}}",
"secret": [{{range $index, $element := (getvs "/lisk/forging/secret/*")}}{{$data := split $element ":"}}{{if $index}},{{end}}
{
"encryptedSecret": "{{index $data 0}}",
"publicKey": "{{index $data 1}}"
}{{end}}
],
"access": {
{{$whiteListEntries := getvs "/lisk/forging/whitelist/*"}}"whiteList": [{{range $index, $element := $whiteListEntries}}{{if $index}},{{end}}"{{$element}}"{{end}}]
}
},
"syncing": {
"active": {{getv "/lisk/syncing/active" "true"}}
},
"loading": {
"verifyOnLoading": {{getv "/lisk/loading/verify" "false"}},
"loadPerIteration": {{getv "/lisk/loading/loadperiteration" "5000"}}
},
"ssl": {
"enabled": {{getv "/lisk/ssl/enabled" "false"}},
"options": {
"port":{{getv "/lisk/ssl/port" "443"}},
"address": "0.0.0.0",
"key": "{{getv "/lisk/ssl/key" "./ssl/lisk.key"}}",
"cert": "{{getv "/lisk/ssl/cert" "./ssl/lisk.crt"}}"
}
},
"nethash": "{{getv "/lisk/nethash" "ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511"}}"
}
20 changes: 3 additions & 17 deletions images/lisk/files/home/lisk/run.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
#!/bin/bash

function jq_config {
jq -c "$1" config.json |sponge config.json
}

jq_config ".api.access.public = true"

jq_config ".consoleLogLevel = \"${LISK_CONFIG_CONSOLE_LOG_LEVEL:=info}\""

if [ "${LISK_CONFIG_FORGING_WHITELIST_IP:=127.0.0.1}" != "127.0.0.1" ]
then
jq_config ".forging.access.whiteList = [\"127.0.0.1\",\"$LISK_CONFIG_FORGING_WHITELIST_IP\"]"
fi
jq_config ".db.host = \"${LISK_CONFIG_DB_HOST:=db}\""
jq_config ".db.port = ${LISK_CONFIG_DB_PORT:=5432}"
jq_config ".db.database = \"${LISK_CONFIG_DB_DATABASE:=lisk_test}\""
jq_config ".db.user = \"${LISK_CONFIG_DB_USER:=lisk}\""
jq_config ".db.password = \"${LISK_CONFIG_DATABASE_PASSWORD:=password}\""
# generate config
confd -onetime -backend env

# launch Lisk Core
export PATH=/home/lisk/lisk-Linux-x86_64/bin:$PATH
export LD_LIBRARY_PATH=/home/lisk/lisk-Linux-x86_64/pgsql/lib
node app.js

0 comments on commit c8b49ff

Please sign in to comment.