diff --git a/README.md b/README.md index ff1d4a5..e96aab2 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Currently used to make sure callbacks have been called for missed transactions. # How to use cyphernode? -The core component of cyphernode is a request handler which exposes HTTP endpoints via REST API, acting as an absctration layer between your apps and the open-source Bitcoin sofware you want to interact with. +The core component of cyphernode is a request handler which exposes HTTP endpoints via REST API, acting as an abstraction layer between your apps and the open-source Bitcoin sofware you want to interact with. ## Documentation diff --git a/api_auth_docker/Dockerfile b/api_auth_docker/Dockerfile index ab22ed9..aa178dc 100644 --- a/api_auth_docker/Dockerfile +++ b/api_auth_docker/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:alpine +FROM nginx:1.18.0-alpine RUN apk add --update --no-cache \ bash \ diff --git a/build.sh b/build.sh index b5d93a5..8948a75 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ TRACING=1 -# CYPHERNODE VERSION "v0.6.0-dev" +# CYPHERNODE VERSION "v0.6.0-dev", dev over v0.6.0 CONF_VERSION="v0.6.0-dev-local" GATEKEEPER_VERSION="v0.6.0-dev-local" TOR_VERSION="v0.6.0-dev-local" @@ -11,8 +11,6 @@ NOTIFIER_VERSION="v0.6.0-dev-local" PROXYCRON_VERSION="v0.6.0-dev-local" OTSCLIENT_VERSION="v0.6.0-dev-local" PYCOIN_VERSION="v0.6.0-dev-local" -BITCOIN_VERSION="v0.21.0" -LIGHTNING_VERSION="v0.9.1" trace() { diff --git a/cron_docker/Dockerfile b/cron_docker/Dockerfile index 44eb442..f9710d0 100644 --- a/cron_docker/Dockerfile +++ b/cron_docker/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.8 +FROM alpine:3.12.4 RUN apk add --update --no-cache \ curl diff --git a/cyphernodeconf_docker/Dockerfile b/cyphernodeconf_docker/Dockerfile index 9698fe2..df64a55 100644 --- a/cyphernodeconf_docker/Dockerfile +++ b/cyphernodeconf_docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13-alpine3.10 as builder-torgen +FROM golang:1.13.15-alpine3.12 as builder-torgen RUN apk add git build-base @@ -13,7 +13,7 @@ RUN go get RUN go build torgen.go RUN chmod +x /go/src/torgen/torgen -FROM alpine:3.11.0 as builder-qrencode +FROM alpine:3.12.4 as builder-qrencode RUN apk add --update --no-cache \ autoconf \ @@ -30,7 +30,7 @@ RUN git clone -b v4.1.0 https://github.com/fukuchi/libqrencode.git \ && make \ && make install -FROM node:12.2.0-alpine +FROM node:15.11.0-alpine3.12 ENV EDITOR=/usr/bin/nano diff --git a/cyphernodeconf_docker/package-lock.json b/cyphernodeconf_docker/package-lock.json index 6b2f2a5..41ef21e 100644 --- a/cyphernodeconf_docker/package-lock.json +++ b/cyphernodeconf_docker/package-lock.json @@ -5461,9 +5461,9 @@ "dev": true }, "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", "dev": true }, "yargs": { diff --git a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml index ecf718b..00b7c74 100644 --- a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml +++ b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml @@ -22,12 +22,20 @@ services: networks: - cyphernodenet - cyphernodeappsnet - <% if (docker_mode == 'compose') { %> + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> restart: always <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] <% } %> <% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %> @@ -54,16 +62,24 @@ services: stop_grace_period: 30s networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> <% if ( features.indexOf('tor') !== -1 ) { %> depends_on: - tor <% } %> -# deploy: --lightning-dir=/.lightning -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> <% } %> <% if( bitcoin_mode === 'internal' ) { %> @@ -90,16 +106,24 @@ services: stop_grace_period: 30s networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> <% if ( features.indexOf('tor') !== -1 ) { %> depends_on: - tor <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> <% } %> ########################## @@ -150,12 +174,20 @@ services: <% } %> networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> restart: always <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] ########################## # PROXYCRON # @@ -168,14 +200,22 @@ services: - "OTS_URL=proxy:8888/ots_backoffice" networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> depends_on: - proxy -# deploy: -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> ########################## # BROKER # @@ -186,12 +226,20 @@ services: networks: - cyphernodenet - cyphernodeappsnet - <% if (docker_mode == 'compose') { %> + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> restart: always <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] ########################## # NOTIFIER # @@ -210,14 +258,22 @@ services: networks: - cyphernodenet - cyphernodeappsnet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> depends_on: - broker -# deploy: -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> ########################## # PYCOIN # @@ -237,12 +293,20 @@ services: - "<%= logs_datapath %>:/cnlogs" networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> restart: always <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] <% if ( features.indexOf('otsclient') !== -1 ) { %> ########################## @@ -269,12 +333,20 @@ services: command: $USER /script/startotsclient.sh networks: - cyphernodenet - <% if (docker_mode == 'compose') { %> + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> restart: always <% } %> -# deploy: -# placement: -# constraints: [node.hostname==dev] <% } %> ########################## @@ -305,14 +377,22 @@ services: networks: - cyphernodenet - cyphernodeappsnet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> depends_on: - proxy -# deploy: -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> ########################## # TRAEFIK # @@ -330,14 +410,22 @@ services: - "<%= traefik_datapath%>/htpasswd:/htpasswd/htpasswd:ro" networks: - cyphernodeappsnet - <% if (docker_mode == 'compose') { %> - restart: always - <% } %> depends_on: - gatekeeper -# deploy: -# placement: -# constraints: [node.hostname==dev] + <% if ( docker_mode === 'swarm' ) { %> + deploy: + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + condition: "any" + delay: 1s + update_config: + parallelism: 1 + <% } else { %> + restart: always + <% } %> volumes: container_monitor: diff --git a/cyphernodeconf_docker/templates/installer/testfeatures.sh b/cyphernodeconf_docker/templates/installer/testfeatures.sh index 627c62f..5831922 100644 --- a/cyphernodeconf_docker/templates/installer/testfeatures.sh +++ b/cyphernodeconf_docker/templates/installer/testfeatures.sh @@ -128,7 +128,8 @@ checktor() { echo -en "\r\n\e[1;36mTesting Tor... " > /dev/console local rc - rc=$(curl -s -o /dev/null -w "%{http_code}" --socks5-hostname tor:9050 http://expyuzz4wqqyqhjn.onion/) + # Testing with onion.torproject.org hidden service. + rc=$(curl -s -o /dev/null -w "%{http_code}" --socks5-hostname tor:9050 http://yz7lpwfhhzcdyc5y.onion/) [ "${rc}" -ne "200" ] && return 250 echo -e "\e[1;36mTor rocks!" > /dev/console diff --git a/cyphernodeconf_docker/templates/traefik/traefik.toml b/cyphernodeconf_docker/templates/traefik/traefik.toml index ccd33d6..e589790 100644 --- a/cyphernodeconf_docker/templates/traefik/traefik.toml +++ b/cyphernodeconf_docker/templates/traefik/traefik.toml @@ -17,6 +17,7 @@ endpoint = "unix:///var/run/docker.sock" domain = "cyphernode.localhost" watch = true exposedByDefault = false +swarmMode = <%= ( docker_mode === 'swarm' )?'true':'false' %> [acme] email = "letsencrypt@yourdomain.com" diff --git a/dist/setup.sh b/dist/setup.sh index 811186d..321a6a6 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -524,25 +524,20 @@ install_docker() { if [[ $FEATURE_LIGHTNING == true ]]; then if [[ $LIGHTNING_IMPLEMENTATION == "c-lightning" ]]; then - local dockerfile="Dockerfile" - if [[ $archpath == "rpi" ]]; then - dockerfile="Dockerfile-alpine" - fi + if [ ! -d $LIGHTNING_DATAPATH/bitcoin ]; then + step " create $LIGHTNING_DATAPATH" + sudo_if_required mkdir -p $LIGHTNING_DATAPATH/bitcoin + next + fi - if [ ! -d $LIGHTNING_DATAPATH/bitcoin ]; then - step " create $LIGHTNING_DATAPATH" - sudo_if_required mkdir -p $LIGHTNING_DATAPATH/bitcoin - next - fi + copy_file $cyphernodeconf_filepath/lightning/c-lightning/config $LIGHTNING_DATAPATH/config 1 $SUDO_REQUIRED + copy_file $cyphernodeconf_filepath/lightning/c-lightning/entrypoint.sh $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh 1 $SUDO_REQUIRED - copy_file $cyphernodeconf_filepath/lightning/c-lightning/config $LIGHTNING_DATAPATH/config 1 $SUDO_REQUIRED - copy_file $cyphernodeconf_filepath/lightning/c-lightning/entrypoint.sh $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh 1 $SUDO_REQUIRED - - if [[ ! -x $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh ]]; then - step " make entrypoint.sh executable" - sudo_if_required chmod +x $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh - next - fi + if [[ ! -x $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh ]]; then + step " make entrypoint.sh executable" + sudo_if_required chmod +x $LIGHTNING_DATAPATH/bitcoin/entrypoint.sh + next + fi fi fi @@ -557,10 +552,24 @@ install_docker() { docker swarm join-token worker > /dev/null 2>&1 local noSwarm=$?; - if [[ $DOCKER_MODE == 'swarm' && $noSwarm == 1 ]]; then - step " init docker swarm" - try docker swarm init --task-history-limit 1 > /dev/null 2>&1 - next + if [[ $DOCKER_MODE == 'swarm' ]]; then + if [[ $noSwarm == 1 ]]; then + step " init docker swarm" + try docker swarm init --task-history-limit 1 > /dev/null 2>&1 + next + fi + + local localnodeid + localnodeid=$(docker info -f '{{.Swarm.NodeID}}') + + # we only support swarm in single host mode, so all labels needed to spawn containers in the swarm + # are given to the host setup is run on. Setup must be run on any manager, if swarm mode is enabled + # and a swarm was already initialised + if [[ $(docker node inspect ${localnodeid} --format '{{ index .Spec.Labels "io.cyphernode" }}') != "true" ]]; then + step " add docker node label io.cyphernode" + try docker node update --label-add io.cyphernode=true ${localnodeid} > /dev/null 2>&1 + next + fi fi local net_entry=$(docker network ls | grep cyphernodenet); @@ -840,7 +849,7 @@ ALWAYSYES=0 SUDO_REQUIRED=0 AUTOSTART=0 -# CYPHERNODE VERSION "v0.6.0-dev" +# CYPHERNODE VERSION "v0.6.0-dev", dev over v0.6.0 SETUP_VERSION="v0.6.0-dev" CONF_VERSION="v0.6.0-dev" GATEKEEPER_VERSION="v0.6.0-dev" @@ -852,7 +861,7 @@ OTSCLIENT_VERSION="v0.6.0-dev" PYCOIN_VERSION="v0.6.0-dev" CYPHERAPPS_VERSION="dev" BITCOIN_VERSION="v0.21.0" -LIGHTNING_VERSION="v0.9.1" +LIGHTNING_VERSION="v0.9.3" TRAEFIK_VERSION="v1.7.9-alpine" MOSQUITTO_VERSION="1.6" diff --git a/otsclient_docker/Dockerfile b/otsclient_docker/Dockerfile index 7270774..7cce253 100644 --- a/otsclient_docker/Dockerfile +++ b/otsclient_docker/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.9 as builder +FROM alpine:3.12.4 as builder RUN apk add --no-cache --update alpine-sdk bsd-compat-headers \ && git clone https://github.com/Kexkey/proxychains-ng.git @@ -9,18 +9,12 @@ RUN cd /proxychains-ng \ && make install \ && make install-config -FROM node:11.1-alpine +FROM node:15.11.0-alpine3.12 RUN apk add --update --no-cache \ - git \ jq \ su-exec \ - && git clone https://github.com/opentimestamps/javascript-opentimestamps.git \ - && cd javascript-opentimestamps \ -# Handle 'Error: could not get uid/gid' -# See: https://github.com/npm/uid-number/issues/3 - && npm config set unsafe-perm true \ - && npm install -g + && npm install -g opentimestamps WORKDIR /script diff --git a/proxy_docker/Dockerfile b/proxy_docker/Dockerfile index 334a96f..1543480 100644 --- a/proxy_docker/Dockerfile +++ b/proxy_docker/Dockerfile @@ -1,4 +1,4 @@ -FROM cyphernode/alpine-glibc-base:v3.11.0_2.29-0 +FROM cyphernode/alpine-glibc-base:v3.12.4_2.31-0 ENV HOME /proxy @@ -12,7 +12,7 @@ WORKDIR ${HOME} COPY app/data/* ./ COPY app/script/* ./ -COPY --from=cyphernode/clightning:v0.9.1 /usr/local/bin/lightning-cli ./ +COPY --from=cyphernode/clightning:v0.9.3 /usr/local/bin/lightning-cli ./ COPY --from=eclipse-mosquitto:1.6 /usr/bin/mosquitto_rr /usr/bin/mosquitto_sub /usr/bin/mosquitto_pub /usr/bin/ COPY --from=eclipse-mosquitto:1.6 /usr/lib/libmosquitto* /usr/lib/ COPY --from=eclipse-mosquitto:1.6 /usr/lib/libcrypto* /usr/lib/ diff --git a/pycoin_docker/Dockerfile b/pycoin_docker/Dockerfile index 32b820b..9b9b484 100644 --- a/pycoin_docker/Dockerfile +++ b/pycoin_docker/Dockerfile @@ -1,12 +1,12 @@ -FROM python:3.6-alpine3.8 +FROM python:3.8.6-alpine3.12 ENV HOME /pycoin RUN apk add --update --no-cache git jq su-exec \ && cd / \ && git clone https://github.com/Kexkey/pycoin.git \ - && mkdir /usr/local/lib/python3.6/site-packages/pycoin \ - && cp -rf pycoin/pycoin/* /usr/local/lib/python3.6/site-packages/pycoin \ + && mkdir /usr/local/lib/python3.8/site-packages/pycoin \ + && cp -rf pycoin/pycoin/* /usr/local/lib/python3.8/site-packages/pycoin \ && rm -rf pycoin/* COPY script/pycoin.sh ${HOME}/pycoin.sh diff --git a/tor_docker/Dockerfile b/tor_docker/Dockerfile index 45fd86d..bde5e96 100644 --- a/tor_docker/Dockerfile +++ b/tor_docker/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.12 AS builder +FROM alpine:3.12.4 AS builder -ARG TOR_VER=0.4.4.5 +ARG TOR_VER=0.4.5.6 ARG TORGZ=https://dist.torproject.org/tor-$TOR_VER.tar.gz RUN apk --no-cache add --update \ @@ -17,7 +17,7 @@ RUN gpg --keyserver pool.sks-keyservers.net --recv-keys 0xFE43009C4607B1FB 0x6AF && tar xfz tor-$TOR_VER.tar.gz && cd tor-$TOR_VER \ && ./configure && make install -FROM alpine:3.12 +FROM alpine:3.12.4 RUN apk --no-cache add --update \ su-exec