diff --git a/build.sh b/build.sh index fdda705..59516e3 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ TRACING=1 -# CYPHERNODE VERSION "v0.1.1" +# CYPHERNODE VERSION "v0.2.0" CONF_VERSION="v0.2.0-local" GATEKEEPER_VERSION="v0.2.0-local" PROXY_VERSION="v0.2.0-local" @@ -27,53 +27,18 @@ trace_rc() fi } - -build_docker_image() { - - local dockerfile="Dockerfile" - - if [[ ""$3 != "" ]]; then - dockerfile=$3 - fi - - trace "building docker image: $2" - #docker build -q $1 -f $1/$dockerfile -t $2:latest > /dev/null - docker build $1 -f $1/$dockerfile -t $2 - -} - build_docker_images() { trace "Updating SatoshiPortal repos" -# git submodule update --recursive --remote - - local bitcoin_dockerfile=Dockerfile.amd64 - local clightning_dockerfile=Dockerfile.amd64 - local proxy_dockerfile=Dockerfile.amd64 - local grafana_dockerfile=Dockerfile.amd64 - - # compat mode for SatoshiPortal repo - # TODO: add more mappings? - if [[ $(uname -m) == 'armv7l' ]]; then - bitcoin_dockerfile="Dockerfile.arm32v6" - clightning_dockerfile="Dockerfile.arm32v6" - proxy_dockerfile="Dockerfile.arm32v6" - grafana_dockerfile="Dockerfile.arm32v6" - fi trace "Creating cyphernodeconf image" - build_docker_image install/ cyphernode/cyphernodeconf:$CONF_VERSION - - trace "Creating SatoshiPortal images" -# build_docker_image install/SatoshiPortal/dockers/bitcoin-core cyphernode/bitcoin:$BITCOIN_VERSION $bitcoin_dockerfile -# build_docker_image install/SatoshiPortal/dockers/c-lightning cyphernode/clightning:$LIGHTNING_VERSION $clightning_dockerfile + docker build install/ -t cyphernode/cyphernodeconf:$CONF_VERSION trace "Creating cyphernode images" - build_docker_image api_auth_docker/ cyphernode/gatekeeper:$GATEKEEPER_VERSION - build_docker_image proxy_docker/ cyphernode/proxy:$PROXY_VERSION $proxy_dockerfile - build_docker_image cron_docker/ cyphernode/proxycron:$PROXYCRON_VERSION - build_docker_image pycoin_docker/ cyphernode/pycoin:$PYCOIN_VERSION - build_docker_image otsclient_docker/ cyphernode/otsclient:$OTSCLIENT_VERSION - + docker build api_auth_docker/ -t cyphernode/gatekeeper:$GATEKEEPER_VERSION + docker build proxy_docker/ -t cyphernode/proxy:$PROXY_VERSION + docker build cron_docker/ -t cyphernode/proxycron:$PROXYCRON_VERSION + docker build pycoin_docker/ -t cyphernode/pycoin:$PYCOIN_VERSION + docker build otsclient_docker/ -t cyphernode/otsclient:$OTSCLIENT_VERSION } build_docker_images diff --git a/dist/setup.sh b/dist/setup.sh index bb68b4d..f84e6b7 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -711,14 +711,14 @@ AUTOSTART=0 # CYPHERNODE VERSION "v0.1.1" VERSION_OVERRIDE="true" -CONF_VERSION="v0.2.0" -GATEKEEPER_VERSION="v0.2.0" -PROXY_VERSION="v0.2.0" -PROXYCRON_VERSION="v0.2.0" -OTSCLIENT_VERSION="v0.2.0" -PYCOIN_VERSION="v0.2.0" -BITCOIN_VERSION="v0.17.1" -LIGHTNING_VERSION="v0.7.0" +CONF_VERSION="v0.2.0-test" +GATEKEEPER_VERSION="v0.2.0-test" +PROXY_VERSION="v0.2.0-test" +PROXYCRON_VERSION="v0.2.0-test" +OTSCLIENT_VERSION="v0.2.0-test" +PYCOIN_VERSION="v0.2.0-test" +BITCOIN_VERSION="v0.17.1-test" +LIGHTNING_VERSION="v0.7.0-test" SETUP_DIR=$(dirname $(realpath $0)) diff --git a/docker-build.sh b/docker-build.sh index 82304d3..040c62e 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -10,14 +10,13 @@ image() { local image=$1 local dir=$2 local arch=$3 - local dockerfile=${4:-"Dockerfile"} echo "Building and pushing $image from $dir for $arch using $dockerfile tagging as $v1, $v2 and $v3..." - docker build -t cyphernode/${image}:${arch}-${v3} -t cyphernode/${image}:${arch}-${v2} -t cyphernode/${image}:${arch}-${v1} -f ${dir}/${dockerfile} ${dir}/. \ -&& docker push cyphernode/${image}:${arch}-${v3} \ -&& docker push cyphernode/${image}:${arch}-${v2} \ -&& docker push cyphernode/${image}:${arch}-${v1} + docker build -t cyphernode/${image}:${arch}-${v3} -t cyphernode/${image}:${arch}-${v2} -t cyphernode/${image}:${arch}-${v1} ${dir}/. \ + && docker push cyphernode/${image}:${arch}-${v3} \ + && docker push cyphernode/${image}:${arch}-${v2} \ + && docker push cyphernode/${image}:${arch}-${v1} return $? } @@ -27,86 +26,64 @@ manifest() { echo "Creating and pushing manifest for $image for version $v3..." - docker manifest create cyphernode/${image}:${v3} cyphernode/${image}:${arm}-${v3} cyphernode/${image}:${x86}-${v3} \ -&& docker manifest annotate cyphernode/${image}:${v3} cyphernode/${image}:${arm}-${v3} --os linux --arch arm \ -&& docker manifest annotate cyphernode/${image}:${v3} cyphernode/${image}:${x86}-${v3} --os linux --arch amd64 \ -&& docker manifest push -p cyphernode/${image}:${v3} + docker manifest create cyphernode/${image}:${v3} cyphernode/${image}:${arm_docker}-${v3} cyphernode/${image}:${x86_docker}-${v3} cyphernode/${image}:${aarch64_docker}-${v3} \ + && docker manifest annotate cyphernode/${image}:${v3} cyphernode/${image}:${arm_docker}-${v3} --os linux --arch ${arm_docker} \ + && docker manifest annotate cyphernode/${image}:${v3} cyphernode/${image}:${x86_docker}-${v3} --os linux --arch ${x86_docker} \ + && docker manifest annotate cyphernode/${image}:${v3} cyphernode/${image}:${aarch64_docker}-${v3} --os linux --arch ${aarch64_docker} \ + && docker manifest push -p cyphernode/${image}:${v3} [ $? -ne 0 ] && return 1 echo "Creating and pushing manifest for $image for version $v2..." - docker manifest create cyphernode/${image}:${v2} cyphernode/${image}:${arm}-${v2} cyphernode/${image}:${x86}-${v2} \ -&& docker manifest annotate cyphernode/${image}:${v2} cyphernode/${image}:${arm}-${v2} --os linux --arch arm \ -&& docker manifest annotate cyphernode/${image}:${v2} cyphernode/${image}:${x86}-${v2} --os linux --arch amd64 \ -&& docker manifest push -p cyphernode/${image}:${v2} + docker manifest create cyphernode/${image}:${v2} cyphernode/${image}:${arm_docker}-${v2} cyphernode/${image}:${x86_docker}-${v2} cyphernode/${image}:${aarch64_docker}-${v2} \ + && docker manifest annotate cyphernode/${image}:${v2} cyphernode/${image}:${arm_docker}-${v2} --os linux --arch ${arm_docker} \ + && docker manifest annotate cyphernode/${image}:${v2} cyphernode/${image}:${x86_docker}-${v2} --os linux --arch ${x86_docker} \ + && docker manifest annotate cyphernode/${image}:${v2} cyphernode/${image}:${aarch64_docker}-${v2} --os linux --arch ${aarch64_docker} \ + && docker manifest push -p cyphernode/${image}:${v2} [ $? -ne 0 ] && return 1 echo "Creating and pushing manifest for $image for version $v1..." - docker manifest create cyphernode/${image}:${v1} cyphernode/${image}:${arm}-${v1} cyphernode/${image}:${x86}-${v1} \ -&& docker manifest annotate cyphernode/${image}:${v1} cyphernode/${image}:${arm}-${v1} --os linux --arch arm \ -&& docker manifest annotate cyphernode/${image}:${v1} cyphernode/${image}:${x86}-${v1} --os linux --arch amd64 \ -&& docker manifest push -p cyphernode/${image}:${v1} + docker manifest create cyphernode/${image}:${v1} cyphernode/${image}:${arm_docker}-${v1} cyphernode/${image}:${x86_docker}-${v1} cyphernode/${image}:${aarch64_docker}-${v1} \ + && docker manifest annotate cyphernode/${image}:${v1} cyphernode/${image}:${arm_docker}-${v1} --os linux --arch ${arm_docker} \ + && docker manifest annotate cyphernode/${image}:${v1} cyphernode/${image}:${x86_docker}-${v1} --os linux --arch ${x86_docker} \ + && docker manifest annotate cyphernode/${image}:${v1} cyphernode/${image}:${aarch64_docker}-${v1} --os linux --arch ${aarch64_docker} \ + && docker manifest push -p cyphernode/${image}:${v1} return $? - } -image_dockers() { - local image=$1 - local dir=$2 - local v=$3 - local arch=$4 - local dockerfile=${5:-"Dockerfile"} +x86_docker="amd64" +arm_docker="arm" +aarch64_docker="arm64" - echo "Building and pushing $image from $dir for $arch using $dockerfile tagging as $v..." +# Build amd64 and arm64 first, building for arm will trigger the manifest creation and push on hub - docker build -t cyphernode/${image}:${arch}-${v} -f ${dir}/${dockerfile} ${dir}/. \ -&& docker push cyphernode/${image}:${arch}-${v} +#arch_docker=${arm_docker} +#arch_docker=${aarch64_docker} +arch_docker=${x86_docker} - return $? +v1="v0-test" +v2="v0.2-test" +v3="v0.2.0-test" -} +echo "\nBuilding Cyphernode Core containers\n" +echo "arch_docker=$arch_docker\n" -manifest_dockers() { - local image=$1 - local v=$2 - - echo "Creating and pushing manifest for $image for version $v..." - - docker manifest create cyphernode/${image}:${v} cyphernode/${image}:${arm}-${v} cyphernode/${image}:${x86}-${v} \ -&& docker manifest annotate cyphernode/${image}:${v} cyphernode/${image}:${arm}-${v} --os linux --arch arm \ -&& docker manifest annotate cyphernode/${image}:${v} cyphernode/${image}:${x86}-${v} --os linux --arch amd64 \ -&& docker manifest push -p cyphernode/${image}:${v} - - return $? - -} - -x86="amd64" -arm="arm32v6" - -#arch=${arm} -arch=${x86} - -v1="v0" -v2="v0.2" -v3="v0.2.0" - -echo "arch=$arch" - -image "gatekeeper" "api_auth_docker/" ${arch} \ -&& image "proxycron" "cron_docker/" ${arch} \ -&& image "otsclient" "otsclient_docker/" ${arch} \ -&& image "proxy" "proxy_docker/" ${arch} "Dockerfile.${arch}" \ -&& image "pycoin" "pycoin_docker/" ${arch} \ -&& image "cyphernodeconf" "install/" ${arch} +image "gatekeeper" "api_auth_docker/" ${arch_docker} \ +&& image "proxycron" "cron_docker/" ${arch_docker} \ +&& image "otsclient" "otsclient_docker/" ${arch_docker} \ +&& image "proxy" "proxy_docker/" ${arch_docker} \ +&& image "pycoin" "pycoin_docker/" ${arch_docker} \ +&& image "cyphernodeconf" "install/" ${arch_docker} [ $? -ne 0 ] && echo "Error" && exit 1 -[ "${arch}" = "${x86}" ] && echo "Built and pushed amd64 only" && exit 0 +[ "${arch_docker}" = "${x86_docker}" ] && echo "Built and pushed ${arch_docker} only" && exit 0 +[ "${arch_docker}" = "${aarch64_docker}" ] && echo "Built and pushed ${arch_docker} only" && exit 0 +[ "${arch_docker}" = "${arm_docker}" ] && echo "Built and pushed images, now building and pushing manifest for all archs..." manifest "gatekeeper" \ && manifest "proxycron" \ @@ -117,20 +94,3 @@ manifest "gatekeeper" \ [ $? -ne 0 ] && echo "Error" && exit 1 -image_dockers "clightning" "../dockers/c-lightning" "v0.7.0" ${arch} "Dockerfile.${arch}" \ -&& image_dockers "bitcoin" "../dockers/bitcoin-core" "v0.17.1" ${arch} "Dockerfile.${arch}" \ -&& image_dockers "app_welcome" "../cyphernode_welcome" "${v3}" ${arch} \ -&& image_dockers "app_welcome" "../cyphernode_welcome" "${v2}" ${arch} \ -&& image_dockers "app_welcome" "../cyphernode_welcome" "${v1}" ${arch} \ -&& image_dockers "sparkwallet" "../spark-wallet" "v0.2.5" ${arch} "Dockerfile-cyphernode" - -[ $? -ne 0 ] && echo "Error" && exit 1 - -manifest_dockers "clightning" "v0.7.0" \ -&& manifest_dockers "bitcoin" "v0.17.1" \ -&& manifest_dockers "app_welcome" "${v3}" \ -&& manifest_dockers "app_welcome" "${v2}" \ -&& manifest_dockers "app_welcome" "${v1}" \ -&& manifest_dockers "sparkwallet" "v0.2.5" - -[ $? -ne 0 ] && echo "Error" && exit 1 diff --git a/install/Dockerfile b/install/Dockerfile index 34b9138..435f6bd 100644 --- a/install/Dockerfile +++ b/install/Dockerfile @@ -5,7 +5,8 @@ RUN mkdir -p /app RUN mkdir /.config RUN chmod a+rwx /.config -RUN npm install -g yo +# Workaround for https://github.com/npm/uid-number/issues/3 +RUN NPM_CONFIG_UNSAFE_PERM=true npm install -g yo COPY generator-cyphernode /app WORKDIR /app/generator-cyphernode RUN npm link diff --git a/proxy_docker/Dockerfile b/proxy_docker/Dockerfile new file mode 100644 index 0000000..fad4969 --- /dev/null +++ b/proxy_docker/Dockerfile @@ -0,0 +1,23 @@ +FROM cyphernode/alpine-glibc-base:3.8 + +ENV HOME /proxy + +RUN apk add --update --no-cache \ + sqlite \ + jq \ + curl \ + su-exec + +WORKDIR ${HOME} + +COPY app/data/* ./ +COPY app/script/* ./ +COPY --from=cyphernode/clightning:v0.7.0-test /usr/local/bin/lightning-cli ./ + +RUN chmod +x startproxy.sh requesthandler.sh lightning-cli sqlmigrate*.sh waitanyinvoice.sh \ + && chmod o+w . \ + && mkdir db + +VOLUME ["${HOME}/db", "/.lightning"] + +ENTRYPOINT ["su-exec"] diff --git a/proxy_docker/Dockerfile.amd64 b/proxy_docker/Dockerfile.amd64 deleted file mode 100644 index e3aa367..0000000 --- a/proxy_docker/Dockerfile.amd64 +++ /dev/null @@ -1,39 +0,0 @@ -FROM alpine:3.8 - -# Taking care of glibc shit (glibc not natively supported by Alpine but lightning-cli uses it) - -ENV GLIBC_VERSION 2.27-r0 -ENV GLIBC_SHA256 938bceae3b83c53e7fa9cc4135ce45e04aae99256c5e74cf186c794b97473bc7 -ENV GLIBCBIN_SHA256 3a87874e57b9d92e223f3e90356aaea994af67fb76b71bb72abfb809e948d0d6 -# Download and install glibc (https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile) -RUN wget -O /etc/apk/keys/sgerrand.rsa.pub https://github.com/sgerrand/alpine-pkg-glibc/releases/download/$GLIBC_VERSION/sgerrand.rsa.pub \ - && wget -O glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" \ - && echo "$GLIBC_SHA256 glibc.apk" | sha256sum -c - \ - && wget -O glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" \ - && echo "$GLIBCBIN_SHA256 glibc-bin.apk" | sha256sum -c - \ - && apk add --update --no-cache glibc-bin.apk glibc.apk \ - && /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib \ - && echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \ - && rm -rf glibc.apk glibc-bin.apk - -ENV HOME /proxy - -RUN apk add --update --no-cache \ - sqlite \ - jq \ - curl \ - su-exec - -WORKDIR ${HOME} - -COPY app/data/* ./ -COPY app/script/* ./ -COPY --from=cyphernode/clightning:v0.7.0 /usr/local/bin/lightning-cli ./ - -RUN chmod +x startproxy.sh requesthandler.sh lightning-cli sqlmigrate*.sh waitanyinvoice.sh \ - && chmod o+w . \ - && mkdir db - -VOLUME ["${HOME}/db", "/.lightning"] - -ENTRYPOINT ["su-exec"] diff --git a/proxy_docker/Dockerfile.arm32v6 b/proxy_docker/Dockerfile.arm32v6 deleted file mode 100644 index 97ca5ec..0000000 --- a/proxy_docker/Dockerfile.arm32v6 +++ /dev/null @@ -1,35 +0,0 @@ -FROM alpine:3.8 - -# Taking care of glibc shit (glibc not natively supported by Alpine but lightning-cli uses it) - -ENV GLIBC_VERSION 2.27-r0 -# Download and install glibc (https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile) -RUN apk add --update --no-cache wget \ - && wget -O glibc.apk "https://github.com/yangxuan8282/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" \ - && wget -O glibc-bin.apk "https://github.com/yangxuan8282/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" \ - && apk add --allow-untrusted --update --no-cache glibc-bin.apk glibc.apk \ - && /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib \ - && echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \ - && rm -rf glibc.apk glibc-bin.apk - -ENV HOME /proxy - -RUN apk add --update --no-cache \ - sqlite \ - jq \ - curl \ - su-exec - -WORKDIR ${HOME} - -COPY app/data/* ./ -COPY app/script/* ./ -COPY --from=cyphernode/clightning:v0.7.0 /usr/local/bin/lightning-cli ./ - -RUN chmod +x startproxy.sh requesthandler.sh lightning-cli sqlmigrate*.sh waitanyinvoice.sh \ - && chmod o+w . \ - && mkdir db - -VOLUME ["${HOME}/db", "/.lightning"] - -ENTRYPOINT ["su-exec"] diff --git a/proxy_docker/README.md b/proxy_docker/README.md index 9d4bdd9..60e41c2 100644 --- a/proxy_docker/README.md +++ b/proxy_docker/README.md @@ -48,22 +48,6 @@ OTS_FILES=/proxy/otsfiles XPUB_DERIVATION_GAP=100 ``` -## Choose the right architecture - -...by modifying the following line in Dockerfile: - -```shell -COPY app/bin/lightning-cli_x86 ${HOME}/lightning-cli -``` - -...to lightning-cli_arm if running on a RPi. - -## Building docker image - -```shell -docker build -t btcproxyimg . -``` - ## Create sqlite3 database path and give rights ```shell