Skip to content

Commit

Permalink
Merge pull request #11 from Kukks/master
Browse files Browse the repository at this point in the history
Fix docker builder & add docker compose example
  • Loading branch information
gruve-p authored Dec 11, 2018
2 parents 16d59c4 + 23b51e0 commit 1e38e23
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 48 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ test/test_sphinx
tests/.pytest.restart
gossip_store
.pytest_cache

contrib/compose/groestlcoin_datadir/

contrib/compose/clightning_groestlcoin_datadir/
63 changes: 15 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions contrib/compose/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NETWORK=testnet
LIGHTNING_ALIAS=
HOST=127.0.0.1
SPARK_LOGIN=admin:admin
SPARK_WALLET_PORT=9876
7 changes: 7 additions & 0 deletions contrib/compose/README.md
Original file line number Diff line number Diff line change
@@ -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)
56 changes: 56 additions & 0 deletions contrib/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
1 change: 1 addition & 0 deletions contrib/compose/groestlcoin-cli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker exec -ti groestlcoind groestlcoin-cli -datadir="/data" $args
3 changes: 3 additions & 0 deletions contrib/compose/groestlcoin-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker exec -ti groestlcoind groestlcoin-cli -datadir="/data" "$@"
1 change: 1 addition & 0 deletions contrib/compose/groestlcoin-lightning-cli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker exec -ti clightning_groestlcoin lightning-cli $args
3 changes: 3 additions & 0 deletions contrib/compose/groestlcoin-lightning-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker exec -ti clightning_groestlcoin lightning-cli "$@"
15 changes: 15 additions & 0 deletions tools/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@" &
Expand Down

0 comments on commit 1e38e23

Please sign in to comment.