Skip to content

Commit 8161846

Browse files
committed
Bump elements
1 parent 3ef6182 commit 8161846

File tree

4 files changed

+201
-0
lines changed

4 files changed

+201
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [[ "$1" == "elements-cli" || "$1" == "elements-tx" || "$1" == "elementsd" || "$1" == "test_elements" ]]; then
5+
mkdir -p "$ELEMENTS_DATA"
6+
7+
CONFIG_PREFIX=""
8+
CHAIN="$ELEMENTS_CHAIN"
9+
NL=$'\n'
10+
if [[ "$CHAIN" ]]; then
11+
CONFIG_PREFIX="chain=$CHAIN\n[$CHAIN]"
12+
elif [[ "${ELEMENTS_NETWORK}" == "regtest" ]]; then
13+
CHAIN="${ELEMENTS_REGTEST_CHAIN:-regtest}"
14+
elif [[ "${ELEMENTS_NETWORK}" == "testnet" ]]; then
15+
CHAIN="${ELEMENTS_TESTNET_CHAIN:-testnet}"
16+
elif [[ "${ELEMENTS_NETWORK}" == "mainnet" ]]; then
17+
CHAIN="${ELEMENTS_MAINNET_CHAIN:-liquidv1}"
18+
else
19+
CHAIN=""
20+
fi
21+
22+
if [[ "$CHAIN" ]]; then
23+
CONFIG_PREFIX="chain=${CHAIN}${NL}[${CHAIN}]"
24+
fi
25+
26+
if [[ "$ELEMENTS_WALLETDIR" ]] && [[ "$CHAIN" ]]; then
27+
28+
WALLETDIR="$ELEMENTS_WALLETDIR/${CHAIN}"
29+
mkdir -p "$WALLETDIR"
30+
[[ -f "${WALLETDIR}/db.log" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/db.log" "${WALLETDIR}/${CHAIN}/wallets/db.log"
31+
[[ -f "${WALLETDIR}/wallet.dat" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/wallet.dat" "${WALLETDIR}/${CHAIN}/wallets/wallet.dat"
32+
[[ -d "${WALLETDIR}/database" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/database" "${WALLETDIR}/${CHAIN}/wallets/database"
33+
chown -R elements:elements "$WALLETDIR"
34+
CONFIG_PREFIX="${CONFIG_PREFIX}${NL}walletdir=${WALLETDIR}/${CHAIN}/wallets${NL}"
35+
WALLETFILE="${WALLETDIR}/${CHAIN}/wallets/wallet.dat"
36+
if ! [[ -f "${WALLETFILE}" ]]; then
37+
echo "The wallet does not exists, creating it at ${WALLETDIR}..."
38+
gosu elements elements-wallet "-datadir=${WALLETDIR}" "-wallet=" create
39+
fi
40+
fi
41+
42+
cat <<-EOF > "$ELEMENTS_DATA/elements.conf"
43+
${CONFIG_PREFIX}
44+
printtoconsole=1
45+
rpcallowip=::/0
46+
${ELEMENTS_EXTRA_ARGS}
47+
EOF
48+
chown elements:elements "$ELEMENTS_DATA/elements.conf"
49+
50+
if [[ "${ELEMENTS_TORCONTROL}" ]]; then
51+
# Because elementsd only accept torcontrol= host as an ip only, we resolve it here and add to config
52+
TOR_CONTROL_HOST=$(echo ${ELEMENTS_TORCONTROL} | cut -d ':' -f 1)
53+
TOR_CONTROL_PORT=$(echo ${ELEMENTS_TORCONTROL} | cut -d ':' -f 2)
54+
if [[ "$TOR_CONTROL_HOST" ]] && [[ "$TOR_CONTROL_PORT" ]]; then
55+
TOR_IP=$(getent hosts $TOR_CONTROL_HOST | cut -d ' ' -f 1)
56+
echo "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" >> "$ELEMENTS_DATA/elements.conf"
57+
echo "Added "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" to $ELEMENTS_DATA/elements.conf"
58+
else
59+
echo "Invalid ELEMENTS_TORCONTROL"
60+
fi
61+
fi
62+
63+
# ensure correct ownership and linking of data directory
64+
# we do not update group ownership here, in case users want to mount
65+
# a host directory and still retain access to it
66+
chown -R elements "$ELEMENTS_DATA"
67+
ln -sfn "$ELEMENTS_DATA" /home/elements/.elements
68+
chown -h elements:elements /home/elements/.elements
69+
70+
exec gosu elements "$@"
71+
else
72+
exec "$@"
73+
fi
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM debian:buster-slim as builder
2+
3+
RUN set -ex \
4+
&& apt-get update \
5+
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
6+
7+
ENV ELEMENTS_VERSION 23.2.1
8+
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-x86_64-linux-gnu.tar.gz
9+
ENV ELEMENTS_SHA256 75b81d43e1fead0dacce5f4a27dbc10faf57e070a56633645e3f2fa3227b720a
10+
11+
# install elements binaries
12+
RUN set -ex \
13+
&& cd /tmp \
14+
&& wget -qO elements.tar.gz "$ELEMaENTS_URL" \
15+
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \
16+
&& mkdir bin \
17+
&& tar -xzvf elements.tar.gz -C /tmp/bin --strip-components=2 "elements-$ELEMENTS_VERSION/bin/elements-cli" "elements-$ELEMENTS_VERSION/bin/elementsd" "elements-$ELEMENTS_VERSION/bin/elements-wallet" \
18+
&& cd bin \
19+
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64" \
20+
&& echo "0b843df6d86e270c5b0f5cbd3c326a04e18f4b7f9b8457fa497b0454c4b138d7 gosu" | sha256sum -c -
21+
22+
FROM debian:buster-slim
23+
COPY --from=builder "/tmp/bin" /usr/local/bin
24+
25+
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements
26+
27+
# create data directory
28+
ENV ELEMENTS_DATA /data
29+
RUN mkdir "$ELEMENTS_DATA" \
30+
&& chown -R elements:elements "$ELEMENTS_DATA" \
31+
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \
32+
&& chown -h elements:elements /home/elements/.elements
33+
34+
VOLUME /data
35+
36+
COPY docker-entrypoint.sh /entrypoint.sh
37+
ENTRYPOINT ["bash", "/entrypoint.sh"]
38+
39+
EXPOSE 8332 8333 18332 18333 18443 18444
40+
CMD ["elementsd"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Use manifest image which support all architecture
2+
FROM debian:buster-slim as builder
3+
4+
RUN set -ex \
5+
&& apt-get update \
6+
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
7+
8+
ENV ELEMENTS_VERSION 23.2.1
9+
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-arm-linux-gnueabihf.tar.gz
10+
ENV ELEMENTS_SHA256 9640e40685d25c7053a07ba5ad2319632a8d67bed5b2fbdc815163210b2bf0ff
11+
12+
# install elements binaries
13+
RUN set -ex \
14+
&& cd /tmp \
15+
&& wget -qO elements.tar.gz "$ELEMENTS_URL" a\
16+
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \
17+
&& mkdir bin \
18+
&& tar -xzvf elements.tar.gz -C /tmp/bin --strip-components=2 "elements-$ELEMENTS_VERSION/bin/elements-cli" "elements-$ELEMENTS_VERSION/bin/elementsd" "elements-$ELEMENTS_VERSION/bin/elements-wallet" \
19+
&& cd bin \
20+
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-armhf" \
21+
&& echo "171b4a2decc920de0dd4f49278d3e14712da5fa48de57c556f99bcdabe03552e gosu" | sha256sum -c -
22+
23+
# Making sure the builder build an arm image despite being x64
24+
FROM arm32v7/debian:buster-slim
25+
26+
COPY --from=builder "/tmp/bin" /usr/local/bin
27+
#EnableQEMU COPY qemu-arm-static /usr/bin
28+
29+
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements
30+
31+
# create data directory
32+
ENV ELEMENTS_DATA /data
33+
RUN mkdir "$ELEMENTS_DATA" \
34+
&& chown -R elements:elements "$ELEMENTS_DATA" \
35+
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \
36+
&& chown -h elements:elements /home/elements/.elements
37+
38+
VOLUME /data
39+
40+
COPY docker-entrypoint.sh /entrypoint.sh
41+
ENTRYPOINT ["bash", "/entrypoint.sh"]
42+
43+
EXPOSE 8332 8333 18332 18333 18443 18444
44+
CMD ["elementsd"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Use manifest image which support all architecture
2+
FROM debian:buster-slim as builder
3+
4+
RUN set -ex \
5+
&& apt-get update \
6+
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
7+
8+
ENV ELEMENTS_VERSION 23.2.1
9+
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-aarch64-linux-gnu.tar.gz
10+
ENV ELEMENTS_SHA256 1c58616f3c0ca4907ed94974e875b07bd16c07989ec48708d5b4e1210de11304
11+
12+
# install elements binaries
13+
RUN set -ex \
14+
&& cd /tmp \
15+
&& wget -qO elements.tar.gz "$ELEMENTS_URL" \
16+
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \
17+
&& mkdir bin \
18+
&& tar -xzvf elements.tar.gz -C /tmp/bin --strip-components=2 "elements-$ELEMENTS_VERSION/bin/elements-cli" "elements-$ELEMENTS_VERSION/bin/elementsd" "elements-$ELEMENTS_VERSION/bin/elements-wallet" \
19+
&& cd bin \
20+
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-arm64" \
21+
&& echo "5e279972a1c7adee65e3b5661788e8706594b458b7ce318fecbd392492cc4dbd gosu" | sha256sum -c -
22+
23+
# Making sure the builder build an arm image despite being x64
24+
FROM arm64v8/debian:buster-slim
25+
26+
COPY --from=builder "/tmp/bin" /usr/local/bin
27+
#EnableQEMU COPY qemu-aarch64-static /usr/bin
28+
29+
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements
30+
31+
# create data directory
32+
ENV ELEMENTS_DATA /data
33+
RUN mkdir "$ELEMENTS_DATA" \
34+
&& chown -R elements:elements "$ELEMENTS_DATA" \
35+
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \
36+
&& chown -h elements:elements /home/elements/.elements
37+
a
38+
VOLUME /data
39+
40+
COPY docker-entrypoint.sh /entrypoint.sh
41+
ENTRYPOINT ["bash", "/entrypoint.sh"]
42+
43+
EXPOSE 8332 8333 18332 18333 18443 18444
44+
CMD ["elementsd"]

0 commit comments

Comments
 (0)