Skip to content

Commit 49496ab

Browse files
NicolasDoriercdecker
authored andcommitted
[Docker] Use stretch-slim instead of Alpine
1 parent 8f8e955 commit 49496ab

File tree

1 file changed

+55
-58
lines changed

1 file changed

+55
-58
lines changed

Dockerfile

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
FROM alpine:3.7 as builder
2-
3-
RUN apk add --no-cache \
4-
ca-certificates \
5-
autoconf \
6-
automake \
7-
build-base \
8-
libressl \
9-
libtool \
10-
gmp-dev \
11-
python \
12-
python-dev \
13-
python3 \
14-
py3-mako \
15-
sqlite-dev \
16-
wget \
17-
git \
18-
file \
19-
gnupg \
20-
swig \
21-
zlib-dev
1+
# This dockerfile is meant to compile a c-lightning x64 image
2+
# It is using multi stage build:
3+
# * downloader: Download litecoin/bitcoin and qemu binaries needed for c-lightning
4+
# * builder: Compile c-lightning dependencies, then c-lightning itself with static linking
5+
# * final: Copy the binaries required at runtime
6+
# The resulting image uploaded to dockerhub will only contain what is needed for runtime.
7+
# From the root of the repository, run "docker build -t yourimage:yourtag ."
8+
FROM debian:stretch-slim as downloader
9+
10+
RUN set -ex \
11+
&& apt-get update \
12+
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr wget
2213

2314
WORKDIR /opt
2415

16+
RUN wget -qO /opt/tini "https://github.com/krallin/tini/releases/download/v0.18.0/tini" \
17+
&& echo "12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855 /opt/tini" | sha256sum -c - \
18+
&& chmod +x /opt/tini
19+
2520
ARG BITCOIN_VERSION=0.17.0
2621
ENV BITCOIN_TARBALL bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
2722
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/$BITCOIN_TARBALL
2823
ENV BITCOIN_ASC_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/SHA256SUMS.asc
29-
ENV BITCOIN_PGP_KEY 01EA5486DE18A882D4C2684590C8019E36C2E964
3024

3125
RUN mkdir /opt/bitcoin && cd /opt/bitcoin \
3226
&& wget -qO $BITCOIN_TARBALL "$BITCOIN_URL" \
33-
&& gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$BITCOIN_PGP_KEY" \
3427
&& wget -qO bitcoin.asc "$BITCOIN_ASC_URL" \
35-
&& gpg --verify bitcoin.asc \
3628
&& grep $BITCOIN_TARBALL bitcoin.asc | tee SHA256SUMS.asc \
3729
&& sha256sum -c SHA256SUMS.asc \
3830
&& BD=bitcoin-$BITCOIN_VERSION/bin \
@@ -43,62 +35,67 @@ ENV LITECOIN_VERSION 0.16.3
4335
ENV LITECOIN_PGP_KEY FE3348877809386C
4436
ENV LITECOIN_URL https://download.litecoin.org/litecoin-${LITECOIN_VERSION}/linux/litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz
4537
ENV LITECOIN_ASC_URL https://download.litecoin.org/litecoin-${LITECOIN_VERSION}/linux/litecoin-${LITECOIN_VERSION}-linux-signatures.asc
38+
ENV LITECOIN_SHA256 686d99d1746528648c2c54a1363d046436fd172beadaceea80bdc93043805994
4639

4740
# install litecoin binaries
4841
RUN mkdir /opt/litecoin && cd /opt/litecoin \
4942
&& wget -qO litecoin.tar.gz "$LITECOIN_URL" \
50-
&& gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$LITECOIN_PGP_KEY" \
51-
&& wget -qO litecoin.asc "$LITECOIN_ASC_URL" \
52-
&& gpg --verify litecoin.asc \
43+
&& echo "$LITECOIN_SHA256 litecoin.tar.gz" | sha256sum -c - \
5344
&& BD=litecoin-$LITECOIN_VERSION/bin \
5445
&& tar -xzvf litecoin.tar.gz $BD/litecoin-cli --strip-components=1 --exclude=*-qt \
5546
&& rm litecoin.tar.gz
5647

48+
FROM debian:stretch-slim as builder
49+
5750
ENV LIGHTNINGD_VERSION=master
51+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates autoconf automake build-essential git libtool python python3 python3-mako wget gnupg dirmngr git
52+
53+
RUN wget -q https://zlib.net/zlib-1.2.11.tar.gz \
54+
&& tar xvf zlib-1.2.11.tar.gz \
55+
&& cd zlib-1.2.11 \
56+
&& ./configure \
57+
&& make \
58+
&& make install && cd .. && rm zlib-1.2.11.tar.gz && rm -rf zlib-1.2.11
59+
60+
RUN apt-get install -y --no-install-recommends unzip tclsh \
61+
&& wget -q https://www.sqlite.org/2018/sqlite-src-3260000.zip \
62+
&& unzip sqlite-src-3260000.zip \
63+
&& cd sqlite-src-3260000 \
64+
&& ./configure --enable-static --disable-readline --disable-threadsafe --disable-load-extension \
65+
&& make \
66+
&& make install && cd .. && rm sqlite-src-3260000.zip && rm -rf sqlite-src-3260000
67+
68+
RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \
69+
&& tar xvf gmp-6.1.2.tar.xz \
70+
&& cd gmp-6.1.2 \
71+
&& ./configure --disable-assembly \
72+
&& make \
73+
&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2
5874

5975
WORKDIR /opt/lightningd
6076
COPY . /tmp/lightning
6177
RUN git clone --recursive /tmp/lightning . && \
6278
git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD)
6379

6480
ARG DEVELOPER=0
65-
RUN ./configure --prefix=/tmp/lightning_install && make -j3 DEVELOPER=${DEVELOPER} && make install
66-
67-
FROM alpine:3.7
68-
69-
RUN apk add --no-cache \
70-
gmp-dev \
71-
sqlite-dev \
72-
inotify-tools \
73-
socat \
74-
bash \
75-
zlib-dev \
76-
tini
77-
78-
ENV GLIBC_VERSION 2.27-r0
79-
ENV GLIBC_SHA256 938bceae3b83c53e7fa9cc4135ce45e04aae99256c5e74cf186c794b97473bc7
80-
ENV GLIBCBIN_SHA256 3a87874e57b9d92e223f3e90356aaea994af67fb76b71bb72abfb809e948d0d6
81-
# Download and install glibc (https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile)
82-
RUN apk add --update curl && \
83-
curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://github.com/sgerrand/alpine-pkg-glibc/releases/download/$GLIBC_VERSION/sgerrand.rsa.pub && \
84-
curl -Lo glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \
85-
echo "$GLIBC_SHA256 glibc.apk" | sha256sum -c - && \
86-
curl -Lo glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" && \
87-
echo "$GLIBCBIN_SHA256 glibc-bin.apk" | sha256sum -c - && \
88-
apk add glibc-bin.apk glibc.apk && \
89-
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
90-
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
91-
apk del curl && \
92-
rm -rf glibc.apk glibc-bin.apk /var/cache/apk/*
81+
RUN ./configure --prefix=/tmp/lightning_install --enable-static && make -j3 DEVELOPER=${DEVELOPER} && make install
82+
83+
FROM debian:stretch-slim as final
84+
COPY --from=downloader /opt/tini /usr/bin/tini
85+
RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-tools \
86+
&& rm -rf /var/lib/apt/lists/*
9387

9488
ENV LIGHTNINGD_DATA=/root/.lightning
9589
ENV LIGHTNINGD_RPC_PORT=9835
90+
ENV LIGHTNINGD_PORT=9735
9691

92+
RUN mkdir $LIGHTNINGD_DATA && \
93+
touch $LIGHTNINGD_DATA/config
9794
VOLUME [ "/root/.lightning" ]
9895
COPY --from=builder /tmp/lightning_install/ /usr/local/
99-
COPY --from=builder /opt/bitcoin/bin /usr/bin
100-
COPY --from=builder /opt/litecoin/bin /usr/bin
96+
COPY --from=downloader /opt/bitcoin/bin /usr/bin
97+
COPY --from=downloader /opt/litecoin/bin /usr/bin
10198
COPY tools/docker-entrypoint.sh entrypoint.sh
10299

103100
EXPOSE 9735 9835
104-
ENTRYPOINT [ "/sbin/tini", "-g", "--", "./entrypoint.sh" ]
101+
ENTRYPOINT [ "/usr/bin/tini", "-g", "--", "./entrypoint.sh" ]

0 commit comments

Comments
 (0)