# build stage for core lightning and its plugins FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as builder ARG TARGETPLATFORM WORKDIR /build RUN apk update && \ apk add \ alpine-sdk \ autoconf \ automake \ ca-certificates \ cargo \ gettext \ git \ gmp-dev \ libsodium \ libtool \ net-tools \ postgresql-dev \ py3-mako \ python3 \ python3-dev \ sqlite-dev \ sqlite-static \ zlib-dev \ zlib-static ARG CORE_LIGHTNING_GIT_HASH=76cd32387a400a2aee607edaf1e0a06e92e1402f \ CORE_LIGHTNING_REPO=https://github.com/ElementsProject/lightning.git 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 -j $(nproc) install && \ make clean ARG PLUGINS_GIT_HASH=cf96eb63c1687644042ea85acfd3785527fd98d4 \ 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=0673c50e7374ea8f5cb7e302f72b7978c6bd1794 \ CLBOSS_REPO=https://github.com/ZmnSCPxj/clboss.git 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 -j $(nproc) install && \ make clean FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as vls_builder WORKDIR /build RUN apk update && \ apk add \ build-base \ cargo \ git \ grpc \ protobuf \ protobuf-dev \ rust ARG VLS_GIT_HASH=f8dea081b8d3ba292285266c9b304eb1d32ceaad \ VLS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git RUN git clone $VLS_REPO vls RUN cd vls && \ git checkout $VLS_GIT_HASH && \ cargo install --path ./vls-proxy --bin remote_hsmd_socket --profile release --root /usr/local/ && \ cargo clean # final stage with runtime dependencies and pkgs FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as runner LABEL maintainer.0="Lakshya Singh (@king-11)" \ maintainer.1="Dev Random (@devrandom01)" RUN apk update && \ apk add \ python3 \ py3-pip \ postgresql \ bitcoin-cli \ pkgconf \ build-base \ bind-tools \ libev-dev \ curl-dev \ sqlite-dev ARG LIGHTNINGD_UID=101 \ LIGHTNINGD_USER=lightning ARG LIGHTNINGD_HOME=/home/${LIGHTNINGD_USER} ENV LIGHTNINGD_DATA=${LIGHTNINGD_HOME}/.lightning \ LIGHTNINGD_RPC_PORT=9835 \ LIGHTNINGD_PORT=9735 \ BITCOIND_HOME=/root/.bitcoin RUN mkdir -p /usr/local/src/plugins COPY --from=builder /usr/bin/lightningd /usr/bin/lightning-cli /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=clboss_builder /usr/bin/clboss /usr/bin/clboss COPY --from=builder /build/plugins/summary /usr/local/src/plugins/summary COPY --from=vls_builder /usr/local/bin/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 entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh COPY healthcheck.sh /healthcheck.sh RUN chmod +x /healthcheck.sh VOLUME ["${LIGHTNINGD_DATA}"] RUN mkdir -p ${BITCOIND_HOME} && \ chown -R lightning:lightning ${BITCOIND_HOME} COPY bitcoin.conf ${BITCOIND_HOME}/bitcoin.conf COPY testnet-config /testnet-config COPY regtest-config /regtest-config USER lightning RUN pip3 install \ pyln-client \ requests \ packaging HEALTHCHECK --interval=5s --timeout=10s --start-period=5s \ CMD ["/bin/sh", "-c", "/healthcheck.sh"] ENTRYPOINT ["/entrypoint.sh"] CMD ["lightningd"]