Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
163 lines (150 loc) · 6.94 KB
/
Copy pathDockerfile
File metadata and controls
163 lines (150 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
ARG CLN_VERSION=v26.06.9
# Shared base with common dependencies
FROM debian:bookworm-slim AS base
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
build-essential \
git \
pkg-config \
curl && \
rm -rf /var/lib/apt/lists/*
# clboss builder
FROM base AS clboss
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
autoconf-archive \
automake \
libcurl4-gnutls-dev \
libev-dev \
libsqlite3-dev \
libtool \
libunwind-dev && \
rm -rf /var/lib/apt/lists/*
COPY clboss/. /tmp/clboss
WORKDIR /tmp/clboss
RUN autoreconf -i && \
./configure && \
./generate_commit_hash.sh && \
make -j$(nproc) && \
make install && \
strip /usr/local/bin/clboss
# sling - download prebuilt binary
FROM base AS sling
ARG TARGETARCH
ARG SLING_VERSION=v4.3.1
RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* && \
if [ "$TARGETARCH" = "amd64" ]; then SLING_ARCH=x86_64; else SLING_ARCH=aarch64; fi && \
curl -fSL "https://github.com/daywalker90/sling/releases/download/${SLING_VERSION}/sling-${SLING_VERSION}-${SLING_ARCH}-linux-gnu.tar.gz" \
| tar xz -C /usr/local/bin/
# Rust toolchain, shared by rust-teos and the lightningd source build
FROM base AS rust-base
ENV RUST_PROFILE=release \
PATH="/root/.cargo/bin:/root/.local/bin:$PATH" \
PROTOBUF_VERSION=21.12 \
PROTOC=/usr/bin/protoc \
PROTOC_INCLUDE=/usr/local/include
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
autoconf automake ca-certificates dirmngr gettext \
gnupg jq libpq-dev libtool libffi-dev libssl-dev \
protobuf-compiler libev-dev libevent-dev \
qemu-user-static wget unzip tclsh && \
rm -rf /var/lib/apt/lists/* && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
rustup toolchain install stable --component rustfmt --allow-downgrade && \
curl -fsSLO --retry 3 https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-all-${PROTOBUF_VERSION}.tar.gz && \
tar -xzf protobuf-all-${PROTOBUF_VERSION}.tar.gz && \
cp -r protobuf-${PROTOBUF_VERSION}/src/google /usr/local/include/ && \
rm -rf protobuf*
# rust-teos builder
FROM rust-base AS builder-rust
COPY ./rust-teos /tmp/rust-teos
WORKDIR /tmp/rust-teos
RUN cargo install --locked --path teos && \
cargo install --locked --path watchtower-plugin
# lightningd from the signed release tarballs. These hashes come from
# SHA256SUMS-v26.06.9 and -arm64, GPG-verified against maintainer key
# 4E4A142F8BD3C38A56B362ED578CAC08472545C5.
FROM base AS lightningd-tarball
ARG TARGETARCH
ARG CLN_VERSION
ARG CLN_SHA256_AMD64=da19bd04de3ebb2ae525cfc114b69bf45ce1c53fad7877d011b4fcaeacf0e45a
ARG CLN_SHA256_ARM64=8bff3b55e41078fc98fb2f0bc454b975aed6fa858c4fe8d7a77e711f2a73e97e
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends ca-certificates xz-utils && \
rm -rf /var/lib/apt/lists/*
# Ubuntu 22.04 build: its glibc 2.35 runs on bookworm's 2.36, so the runtime
# stays the distro every other binary here is compiled against.
RUN set -eu; \
case "$TARGETARCH" in \
amd64) SHA="$CLN_SHA256_AMD64" ;; \
arm64) SHA="$CLN_SHA256_ARM64" ;; \
*) echo "unsupported TARGETARCH: $TARGETARCH" >&2; exit 1 ;; \
esac; \
TARBALL="clightning-${CLN_VERSION}-Ubuntu-22.04-${TARGETARCH}.tar.xz"; \
curl -fsSLO "https://github.com/ElementsProject/lightning/releases/download/${CLN_VERSION}/${TARBALL}"; \
echo "${SHA} ${TARBALL}" | sha256sum -c -; \
mkdir -p /dist/usr/local; \
tar -xf "$TARBALL" -C /dist/usr/local --strip-components=2
# lightningd built from the release's source zip, for an arch upstream
# published no tarball for. The hash is from the same signed SHA256SUMS.
FROM rust-base AS lightningd-source
ARG CLN_VERSION
ARG CLN_SRC_SHA256=ac37b1b6c41b6c60cf06dd8cd7500f1fab04411cf2f3bc126838d8cafab4538d
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
libsodium-dev libsqlite3-dev zlib1g-dev python3-mako lowdown unzip && \
rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN set -eu; \
ZIP="clightning-${CLN_VERSION}.zip"; \
curl -fsSLO --retry 3 "https://github.com/ElementsProject/lightning/releases/download/${CLN_VERSION}/${ZIP}"; \
echo "${CLN_SRC_SHA256} ${ZIP}" | sha256sum -c -; \
unzip -q "$ZIP"; \
cd "clightning-${CLN_VERSION}"; \
./configure --prefix=/usr/local --disable-valgrind; \
make -j"$(nproc)" install-program DESTDIR=/dist RUST_PROFILE=release VERSION="${CLN_VERSION}"
FROM lightningd-tarball AS lightningd-dist-amd64
FROM lightningd-tarball AS lightningd-dist-arm64
FROM lightningd-dist-${TARGETARCH} AS lightningd-dist
# bitcoin-cli, which CLN's own plugin-bcli and our check-synced health check
# both exec; without it lightningd dies at startup with "The Bitcoin backend
# died". Checksums are from bitcoincore.org's SHA256SUMS.
FROM base AS bitcoin-cli
ARG TARGETARCH
ARG BITCOIN_VERSION=31.1
ARG BITCOIN_SHA256_AMD64=b80d9c3e04da78fb6f0569685673418cf686fadba9042d926d13fb87ff503f9e
ARG BITCOIN_SHA256_ARM64=dcf1873f2208ba4f962f3398d47e154c39c0084be8f4553e05c940d0ace3d004
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN set -eu; \
case "$TARGETARCH" in \
amd64) SHA="$BITCOIN_SHA256_AMD64"; ARCH=x86_64 ;; \
arm64) SHA="$BITCOIN_SHA256_ARM64"; ARCH=aarch64 ;; \
*) echo "unsupported TARGETARCH: $TARGETARCH" >&2; exit 1 ;; \
esac; \
TARBALL="bitcoin-${BITCOIN_VERSION}-${ARCH}-linux-gnu.tar.gz"; \
curl -fsSLO "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/${TARBALL}"; \
echo "${SHA} ${TARBALL}" | sha256sum -c -; \
tar -xf "$TARBALL" "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-cli"; \
install -m 755 "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-cli" /usr/bin/bitcoin-cli
# Final stage - simplified
#
# `ca-certificates` is load-bearing: the slim base carries no CA store, and none
# of the -dev packages below pull one in. Without it watchtower-client cannot
# build an HTTPS client, so no tower ever registers (see README.md).
#
# `libpq5` and `libsodium23` are lightningd's own runtime deps.
FROM debian:bookworm-slim AS final
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates libev-dev libcurl4-gnutls-dev libsqlite3-dev libunwind-dev \
libpq5 libsodium23 wireguard-tools iptables iproute2 procps && \
rm -rf /var/lib/apt/lists/*
COPY --from=bitcoin-cli /usr/bin/bitcoin-cli /usr/bin/bitcoin-cli
COPY --from=lightningd-dist /dist/usr/local /usr/local
COPY --from=clboss /usr/local/bin/clboss /usr/local/libexec/c-lightning/plugins/
COPY --from=builder-rust /root/.cargo/bin/teos* /usr/local/bin/
COPY --from=builder-rust /root/.cargo/bin/watchtower-client /usr/local/libexec/c-lightning/plugins/
COPY --from=sling /usr/local/bin/sling /usr/local/libexec/c-lightning/plugins/