diff --git a/.gitignore b/.gitignore index 7bfeaf75e4e4..d0379c469bde 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ test/test_sphinx tests/.pytest.restart gossip_store .pytest_cache + +contrib/compose/groestlcoin_datadir/ + +contrib/compose/clightning_groestlcoin_datadir/ diff --git a/Dockerfile b/Dockerfile index e4b78ac2bdcf..66263f60d3b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,8 @@ -FROM alpine:3.7 as builder +FROM debian:stretch-slim as builder -RUN apk add --no-cache \ - ca-certificates \ - autoconf \ - automake \ - build-base \ - libressl \ - libtool \ - gmp-dev \ - python \ - python-dev \ - python3 \ - sqlite-dev \ - wget \ - git \ - file \ - gnupg \ - swig \ - zlib-dev +RUN apt-get update && apt-get install -y \ + autoconf automake build-essential git libtool libgmp-dev \ + libsqlite3-dev python python3 net-tools zlib1g-dev wget WORKDIR /opt @@ -28,10 +13,9 @@ ENV GROESTLCOIN_SHA256 f15bd5e38b25a103821f1563cd0e1b2cf7146ec9f9835493a30bd5731 RUN mkdir /opt/groestlcoin && cd /opt/groestlcoin \ && wget -qO groestlcoin.tar.gz "$GROESTLCOIN_URL" \ && echo "$GROESTLCOIN_SHA256 groestlcoin.tar.gz" | sha256sum -c - \ - && BD=groestlcoin-$GROESTLCOIN_VERSION/bin \ - && tar -xzvf groestlcoin.tar.gz $BD/groestlcoin-cli --strip-components=1 --exclude=*-qt \ + && tar -xzvf groestlcoin.tar.gz groestlcoin-cli --exclude=*-qt \ && rm groestlcoin.tar.gz - + ENV LIGHTNINGD_VERSION=master WORKDIR /opt/lightningd @@ -40,40 +24,23 @@ COPY . . ARG DEVELOPER=0 RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/ -FROM alpine:3.7 - -RUN apk add --no-cache \ - gmp-dev \ - sqlite-dev \ - inotify-tools \ - socat \ - bash \ - zlib-dev - -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 apk add --update curl && \ - curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://github.com/sgerrand/alpine-pkg-glibc/releases/download/$GLIBC_VERSION/sgerrand.rsa.pub && \ - curl -Lo glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \ - echo "$GLIBC_SHA256 glibc.apk" | sha256sum -c - && \ - curl -Lo 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 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 && \ - apk del curl && \ - rm -rf glibc.apk glibc-bin.apk /var/cache/apk/* +FROM debian:stretch-slim +RUN apt-get update && apt-get install -y \ + autoconf automake build-essential git libtool libgmp-dev \ + libsqlite3-dev python python3 net-tools zlib1g-dev + ENV LIGHTNINGD_DATA=/root/.lightning ENV LIGHTNINGD_RPC_PORT=9835 +RUN mkdir $LIGHTNINGD_DATA && \ + touch $LIGHTNINGD_DATA/config + VOLUME [ "/root/.lightning" ] COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/ -COPY --from=builder /opt/groestlcoin/bin /usr/bin +COPY --from=builder /opt/groestlcoin /usr/bin COPY tools/docker-entrypoint.sh entrypoint.sh EXPOSE 9735 9835 diff --git a/contrib/compose/.env b/contrib/compose/.env new file mode 100644 index 000000000000..b77f27b8dccc --- /dev/null +++ b/contrib/compose/.env @@ -0,0 +1,5 @@ +NETWORK=testnet +LIGHTNING_ALIAS= +HOST=127.0.0.1 +SPARK_LOGIN=admin:admin +SPARK_WALLET_PORT=9876 \ No newline at end of file diff --git a/contrib/compose/README.md b/contrib/compose/README.md new file mode 100644 index 000000000000..ab5778a964a5 --- /dev/null +++ b/contrib/compose/README.md @@ -0,0 +1,7 @@ +# Docker Compose Quickstart + +This is an example of how to run a GRS node, GRS c-lightning node and Spark wallet + +### Configuration & Running + +Ensure you have docker & docker-compose installed, edit the `.env` options to your liking and run `docker-compose up`. By default it will run testnet and spark wallet wil lbe available at `localhost:9876` (after GRS syncs) diff --git a/contrib/compose/docker-compose.yml b/contrib/compose/docker-compose.yml new file mode 100644 index 000000000000..32839f4a198f --- /dev/null +++ b/contrib/compose/docker-compose.yml @@ -0,0 +1,56 @@ +version: "3" +services: + groestlcoind: + restart: unless-stopped + container_name: groestlcoind + image: nicolasdorier/docker-groestlcoin:2.16.3 + environment: + GROESTLCOIN_EXTRA_ARGS: | + rpcport=43782 + ${NETWORK:-regtest}=1 + port=39388 + whitelist=0.0.0.0/0 + expose: + - "43782" + - "39388" + volumes: + - "./groestlcoin_datadir:/data" + clightning_groestlcoin: + image: kukks/grs-clightning:latest + stop_signal: SIGKILL + container_name: clightning_groestlcoin + restart: unless-stopped + environment: + LIGHTNINGD_NETWORK: ${NETWORK:-regtest} + LIGHTNINGD_OPT: | + bitcoin-datadir=/etc/groestlcoin + bitcoin-rpcconnect=groestlcoind + bitcoin-rpcport=43782 + log-level=debug + announce-addr=${HOST}:9737 + bind-addr=0.0.0.0:9735 + network=${NETWORK:-regtest} + alias=${LIGHTNING_ALIAS} + volumes: + - "clightning_groestlcoin_datadir:/root/.lightning" + - "./groestlcoin_datadir:/etc/groestlcoin" + ports: + - "9735:9735" + links: + - groestlcoind + clightning_groestlcoin_spark: + image: shesek/spark-wallet + container_name: clightning_groestlcoin_spark + restart: unless-stopped + environment: + LOGIN: ${SPARK_LOGIN} + PORT: ${SPARK_WALLET_PORT} + links: + - clightning_groestlcoin + ports: + - "9876:${SPARK_WALLET_PORT}" + volumes: + - "clightning_groestlcoin_datadir:/etc/lightning" + +volumes: + clightning_groestlcoin_datadir: \ No newline at end of file diff --git a/contrib/compose/groestlcoin-cli.ps1 b/contrib/compose/groestlcoin-cli.ps1 new file mode 100644 index 000000000000..63e5e8ce96e8 --- /dev/null +++ b/contrib/compose/groestlcoin-cli.ps1 @@ -0,0 +1 @@ +docker exec -ti groestlcoind groestlcoin-cli -datadir="/data" $args \ No newline at end of file diff --git a/contrib/compose/groestlcoin-cli.sh b/contrib/compose/groestlcoin-cli.sh new file mode 100644 index 000000000000..22a93e696607 --- /dev/null +++ b/contrib/compose/groestlcoin-cli.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -ti groestlcoind groestlcoin-cli -datadir="/data" "$@" \ No newline at end of file diff --git a/contrib/compose/groestlcoin-lightning-cli.ps1 b/contrib/compose/groestlcoin-lightning-cli.ps1 new file mode 100644 index 000000000000..c3e4063e4a47 --- /dev/null +++ b/contrib/compose/groestlcoin-lightning-cli.ps1 @@ -0,0 +1 @@ +docker exec -ti clightning_groestlcoin lightning-cli $args diff --git a/contrib/compose/groestlcoin-lightning-cli.sh b/contrib/compose/groestlcoin-lightning-cli.sh new file mode 100644 index 000000000000..bb5230316f81 --- /dev/null +++ b/contrib/compose/groestlcoin-lightning-cli.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -ti clightning_groestlcoin lightning-cli "$@" diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index 47e5c8cc4970..bebb7d10512c 100755 --- a/tools/docker-entrypoint.sh +++ b/tools/docker-entrypoint.sh @@ -2,6 +2,21 @@ : "${EXPOSE_TCP:=false}" +cat <<-EOF > "$LIGHTNINGD_DATA/config" +${LIGHTNINGD_OPT} +EOF + +NETWORK=$(sed -n 's/^network=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") +REPLACEDNETWORK=""; +if [ "$NETWORK" == "mainnet" ]; then + REPLACEDNETWORK="groestlcoin" +fi +if [[ $REPLACEDNETWORK ]]; then + sed -i '/^network=/d' "$LIGHTNINGD_DATA/config" + echo "network=$REPLACEDNETWORK" >> "$LIGHTNINGD_DATA/config" + echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" +fi + if [ "$EXPOSE_TCP" == "true" ]; then set -m lightningd "$@" &