Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2056 from LiskHQ/2053-dockerfile-config-template
Browse files Browse the repository at this point in the history
Dockerfile with config.json templating - Closes #2053
  • Loading branch information
MaciejBaj authored Jun 6, 2018
2 parents 7812011 + 958ee97 commit 38beb73
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM node:6 AS builder

ENV NODE_ENV=production

RUN apt-get update && \
apt-get --assume-yes upgrade

RUN groupadd --gid 1100 lisk && \
useradd --create-home --home-dir /home/lisk --shell /bin/bash --uid 1100 --gid 1100 lisk
# As of June 2018 cloud.docker.com runs docker 17.06.2-ee-6
# however version 17.12 is required to use the chown flag
COPY . /home/lisk/lisk/
RUN chown lisk:lisk --recursive /home/lisk/lisk

USER lisk
WORKDIR /home/lisk/lisk

RUN npm install


FROM node:6

ENV CONFD_VERSION 0.16.0
ENV CONFD_SHA256 255d2559f3824dd64df059bdc533fd6b697c070db603c76aaf8d1d5e6b0cc334
ENV NODE_ENV=production

RUN apt-get update && \
apt-get --assume-yes upgrade && \
apt-get --assume-yes install jq

RUN groupadd --gid 1100 lisk && \
useradd --create-home --home-dir /home/lisk --shell /bin/bash --uid 1100 --gid 1100 lisk
COPY --from=builder /home/lisk/lisk/ /home/lisk/lisk/
COPY docker_files/ /
# git repository needed for build; cannot be added to .dockerignore
RUN rm -rf /home/lisk/lisk/.git && \
mkdir /home/lisk/lisk/logs && \
chown lisk:lisk --recursive /home/lisk/lisk

RUN curl --silent --show-error --location --output /tmp/confd \
https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 && \
if [ x"$( sha256sum /tmp/confd |awk '{ print $1 }' )" = x"${CONFD_SHA256}" ]; then \
mv /tmp/confd /usr/local/bin/; \
chmod +x /usr/local/bin/confd; \
else \
rm -f /tmp/confd; \
exit 1; \
fi

RUN LISK_VERSION=$( jq --raw-output .version /home/lisk/lisk/config.json ) && \
LISK_MIN_VERSION=$( jq --raw-output .minVersion /home/lisk/lisk/config.json ) && \
sed --in-place --expression \
"s/__LISK_VERSION__REPLACE_ME__/$LISK_VERSION/;s/__LISK_MIN_VERSION__REPLACE_ME__/$LISK_MIN_VERSION/" \
/etc/confd/templates/config.json.tmpl

ENV LISK_API_ACCESS_WHITELIST_1=127.0.0.1
ENV LISK_FORGING_ACCESS_WHITELIST_1=${LISK_API_ACCESS_WHITELIST_1}

USER lisk
WORKDIR /home/lisk/lisk
CMD ["/home/lisk/run.sh"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ Lisk is a next generation crypto-currency and decentralized application platform
<a href="https://david-dm.org/LiskHQ/lisk"><img src="https://david-dm.org/LiskHQ/lisk.svg" alt="Dependency Status"></a>
<a href="https://david-dm.org/LiskHQ/lisk/?type=dev"><img src="https://david-dm.org/LiskHQ/lisk/dev-status.svg" alt="devDependency Status"></a>

## Docker image

### Build

Please refer to the official documentation if you need to install the [Docker Engine](https://docs.docker.com/engine/installation).
To build the image:
```
docker build --tag lisk/mainnet:1.0.0 --build-arg LISK_VERSION=1.0.0 .
```

### Usage

Please refer to the documentation on [lisk.io](https://lisk.io/documentation/core/installation/docker-main-network).

## Prerequisites - In order

This sections provides details on what you need install on your system in order to run Lisk.
Expand Down
6 changes: 6 additions & 0 deletions docker_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 = "config.json"
keys = [
"/lisk",
]
142 changes: 142 additions & 0 deletions docker_files/etc/confd/templates/config.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"wsPort": {{getv "/lisk/wsport" "8001"}},
"httpPort": {{getv "/lisk/httpport" "8000"}},
"address": "{{getv "/lisk/address" "0.0.0.0"}}",
"version": "__LISK_VERSION__REPLACE_ME__",
"minVersion": "__LISK_MIN_VERSION__REPLACE_ME__",
"fileLogLevel": "{{getv "/lisk/fileloglevel" "info"}}",
"logFileName": "{{getv "/lisk/logfilename" "logs/lisk.log"}}",
"consoleLogLevel": "{{getv "/lisk/consoleloglevel" "error"}}",
"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" "localhost"}}",
"port": {{getv "/lisk/db/port" "5432"}},
"database": "{{getv "/lisk/db/database" "lisk_main"}}",
"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/reapintervalmillis" "1000"}},
"logEvents": ["error"],
"logFileName": "{{getv "/lisk/db/logfilename" "logs/lisk_db.log"}}"
},
"redis": {
"host": "{{getv "/lisk/redis/host" "127.0.0.1"}}",
"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/access/public" "false"}},
{{$whiteListEntries := getvs "/lisk/api/access/whitelist/*"}}"whiteList": [{{range $index, $element := $whiteListEntries}}{{if $index}}, {{end}}"{{$element}}"{{end}}]
},
"options": {
"limits": {
"max": {{getv "/lisk/api/options/limits/max" "0"}},
"delayMs": {{getv "/lisk/api/options/limits/delayms" "0"}},
"delayAfter": {{getv "/lisk/api/options/limits/delayafter" "0"}},
"windowMs": {{getv "/lisk/api/options/limits/windowms" "60000"}}
},
"cors": {
"origin": "{{getv "/lil/api/options/cors/origin" "*"}}",
"methods": ["GET", "POST", "PUT"]
}
}
},
"peers": {
"enabled": {{getv "/lisk/peers/enabled" "true"}},
"list": [
{
"ip": "83.136.254.92",
"wsPort": 8000
},
{
"ip": "83.136.249.76",
"wsPort": 8000
},
{
"ip": "94.237.28.66",
"wsPort": 8000
},
{
"ip": "94.237.24.199",
"wsPort": 8000
},
{
"ip": "209.50.49.23",
"wsPort": 8000
},
{
"ip": "209.50.49.40",
"wsPort": 8000
},
{
"ip": "94.237.64.70",
"wsPort": 8000
},
{
"ip": "94.237.64.73",
"wsPort": 8000
},
{
"ip": "94.237.40.140",
"wsPort": 8000
},
{
"ip": "94.237.40.141",
"wsPort": 8000
}
],
"access": {
{{$blackListEntries := getvs "/lisk/peers/access/blacklist/*"}}"blackList": [{{range $index, $element := $blackListEntries}}{{if $index}}, {{end}}"{{$element}}"{{end}}]
},
"options": {
"timeout": {{getv "/lisk/peers/options/timeout" "5000"}},
"broadhashConsensusCalculationInterval": {{getv "/lisk/peers/options/broadhashconsensuscalculationinterval" "5000"}}
}
},
"broadcasts": {
"active": {{getv "/lisk/broadcasts/active" "true"}},
"broadcastInterval": {{getv "/lisk/broadcasts/broadcastinterval" "5000"}},
"broadcastLimit": {{getv "/lisk/broadcasts/broadcastlimit" "20"}},
"parallelLimit": {{getv "/lisk/broadcasts/parallellimit" "20"}},
"releaseLimit": {{getv "/lisk/broadcasts/releaselimit" "25"}},
"relayLimit": {{getv "/lisk/broadcasts/relaylimit" "2"}}
},
"transactions": {
"maxTransactionsPerQueue": {{getv "/lisk/transactions/maxtransactionsperqueue" "1000"}}
},
"forging": {
"force": {{getv "/lisk/forging/force" "false"}},
"delegates": [{{range $index, $element := (getvs "/lisk/forging/delegates/*")}}{{$data := split $element ":"}}{{if $index}}, {{end}}
{
"encryptedSecret": "{{index $data 0}}",
"publicKey": "{{index $data 1}}"
}{{end}}],
"access": {
{{$whiteListEntries := getvs "/lisk/forging/access/whitelist/*"}}"whiteList": [{{range $index, $element := $whiteListEntries}}{{if $index}}, {{end}}"{{$element}}"{{end}}]
}
},
"syncing": {
"active": {{getv "/lisk/syncing/active" "true"}}
},
"loading": {
"loadPerIteration": {{getv "/lisk/loading/loadperiteration" "5000"}}
},
"ssl": {
"enabled": {{getv "/lisk/ssl/enabled" "false"}},
"options": {
"port": {{getv "/lisk/ssl/options/port" "443"}},
"address": "{{getv "/lisk/ssl/options/address" "0.0.0.0"}}",
"key": "{{getv "/lisk/ssl/options/key" "./ssl/lisk.key"}}",
"cert": "{{getv "/lisk/ssl/options/cert" "./ssl/lisk.crt"}}"
}
},
"nethash": "{{getv "/lisk/nethash" "ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511"}}"
}
4 changes: 4 additions & 0 deletions docker_files/home/lisk/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

confd -backend env -onetime
node app.js
Loading

0 comments on commit 38beb73

Please sign in to comment.