cln: remove quotes from env vars

- only build remote_hsmd_socket
- multiple layers for build caching
- download git repo in separate command to prevent redownload
- fix COPY of symlink not possible
- copy the bitcoin.conf file
- add git hook to ensure no difference
Signed-off-by: Lakshya Singh <lakshay.singh1108@gmail.com>
This commit is contained in:
Lakshya Singh 2023-11-07 19:02:45 +05:30
parent f4c13e1a15
commit 6e7178a4c4
No known key found for this signature in database
GPG Key ID: D3239BA6109A2CE7
3 changed files with 75 additions and 35 deletions

3
hooks/pre-commit Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/sh
cmp bitcoind/bitcoin.conf lightningd/bitcoin.conf

View File

@ -1,4 +1,4 @@
# build stage for core lightning and clboss
# build stage for core lightning and its plugins
FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as builder
ARG TARGETPLATFORM
@ -29,51 +29,66 @@ RUN apk update && \
ARG CORE_LIGHTNING_GIT_HASH=bd9494c65be09e6f8ecb3bc49b50a859467a65fe
ARG CORE_LIGHTNING_REPO=https://github.com/lightning-signer/c-lightning.git
RUN git clone --recursive $CORE_LIGHTNING_REPO /repo && \
cd /repo && \
RUN git clone --recursive $CORE_LIGHTNING_REPO core-lightning
RUN cd core-lightning && \
git checkout $CORE_LIGHTNING_GIT_HASH && \
./configure --enable-static --prefix=/usr && \
make -j $(nproc) && \
make install
make -j $(nproc) install
RUN apk add \
autoconf-archive \
bind-tools \
build-base \
curl-dev \
libev-dev \
pkgconf \
sqlite-dev
ARG PLUGINS_GIT_HASH=ce078bb74e10b5dea779fcd9fbe77e1d3e72db7a
ARG PLUGINS_REPO=https://github.com/lightningd/plugins.git
RUN git clone $PLUGINS_REPO
RUN cd plugins && \
git checkout $PLUGINS_GIT_HASH
FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as clboss_builder
WORKDIR /build
RUN apk update && \
apk add \
git \
autoconf-archive \
automake \
bind-tools \
build-base \
curl-dev \
libev-dev \
libtool \
pkgconf \
sqlite-dev
ARG CLBOSS_GIT_HASH=9c050d61f01ffff4b7b5d295f708569dd71b55d3
ARG CLBOSS_REPO=https://github.com/ZmnSCPxj/clboss.git
RUN git clone --recurse-submodules $CLBOSS_REPO /clboss && \
cd /clboss && \
RUN git clone --recurse-submodules $CLBOSS_REPO clboss
RUN cd clboss && \
git checkout $CLBOSS_GIT_HASH && \
autoreconf -i && \
./configure --prefix=/usr && \
make -j $(nproc) && \
make install
ARG PLUGINS_GIT_HASH=ce078bb74e10b5dea779fcd9fbe77e1d3e72db7a
ARG PLUGINS_REPO=https://github.com/lightningd/plugins.git
RUN git clone $PLUGINS_REPO && \
cd plugins && \
git checkout $PLUGINS_GIT_HASH
FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as vls_builder
RUN apk add \
cargo \
rust \
grpc \
protobuf \
protobuf-dev
WORKDIR /build
RUN apk update && \
apk add \
build-base \
cargo \
git \
grpc \
protobuf \
protobuf-dev \
rust
ARG VLS_GIT_HASH=af02dac8b855c361d74234387d288a9591fad1d5
ARG VLS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git
RUN git clone $VLS_REPO && \
cd validating-lightning-signer && \
RUN git clone $VLS_REPO vls
RUN cd vls && \
git checkout $VLS_GIT_HASH && \
cargo build --bins -r
cargo build --bin remote_hsmd_socket --release
# final stage with runtime dependencies and pkgs
FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as runner
@ -110,15 +125,15 @@ COPY --from=builder /usr/bin/lightning-hsmtool /usr/bin/
COPY --from=builder /usr/libexec/c-lightning /usr/libexec/c-lightning
COPY --from=builder /usr/share/man/man8 /usr/share/man/man8
COPY --from=builder /usr/share/doc/c-lightning /usr/share/doc/c-lightning
COPY --from=builder /usr/bin/clboss /usr/bin/clboss
COPY --from=clboss_builder /usr/bin/clboss /usr/bin/clboss
COPY --from=builder /build/plugins/summary /usr/local/src/plugins/summary
COPY --from=builder /build/validating-lightning-signer/target/release/remote_hsmd_socket /usr/libexec/c-lightning/remote_hsmd_socket
COPY --from=vls_builder /build/vls/target/release/remote_hsmd_socket /usr/libexec/c-lightning/remote_hsmd_socket
RUN addgroup -S lightning && adduser -S lightning -G lightning && \
mkdir -p ${LIGHTNINGD_DATA} && \
chown -R lightning:lightning ${LIGHTNINGD_DATA}
COPY bitcoin.conf "${BITCOIND_HOME}"/bitcoin.conf
COPY bitcoin.conf ${BITCOIND_HOME}/bitcoin.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
@ -128,10 +143,10 @@ RUN chmod +x /healthcheck.sh
VOLUME ["${LIGHTNINGD_DATA}"]
RUN mkdir -p "${BITCOIND_HOME}" && \
chown -R lightning:lightning "${BITCOIND_HOME}"
RUN mkdir -p ${BITCOIND_HOME} && \
chown -R lightning:lightning ${BITCOIND_HOME}
COPY bitcoin.conf "${BITCOIND_HOME}"/bitcoin.conf
COPY bitcoin.conf ${BITCOIND_HOME}/bitcoin.conf
COPY testnet-config /testnet-config
COPY regtest-config /regtest-config

View File

@ -1 +0,0 @@
../bitcoind/bitcoin.conf

23
lightningd/bitcoin.conf Normal file
View File

@ -0,0 +1,23 @@
##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##
server=1
rpcallowip=0.0.0.0/0
whitelist=0.0.0.0/0
txindex=1
blockfilterindex=1
[test]
rpcbind=0.0.0.0
rpcuser=rpcuser
rpcpassword=VLSsigner1
rpcport=18332
port=18333
[regtest]
rpcbind=0.0.0.0
rpcuser=rpcuser
rpcpassword=VLSsigner1
rpcport=38332
port=38333