-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ "$1" == "elements-cli" || "$1" == "elements-tx" || "$1" == "elementsd" || "$1" == "test_elements" ]]; then | ||
mkdir -p "$ELEMENTS_DATA" | ||
|
||
CONFIG_PREFIX="" | ||
CHAIN="$ELEMENTS_CHAIN" | ||
NL=$'\n' | ||
if [[ "$CHAIN" ]]; then | ||
CONFIG_PREFIX="chain=$CHAIN\n[$CHAIN]" | ||
elif [[ "${ELEMENTS_NETWORK}" == "regtest" ]]; then | ||
CHAIN="${ELEMENTS_REGTEST_CHAIN:-regtest}" | ||
elif [[ "${ELEMENTS_NETWORK}" == "testnet" ]]; then | ||
CHAIN="${ELEMENTS_TESTNET_CHAIN:-testnet}" | ||
elif [[ "${ELEMENTS_NETWORK}" == "mainnet" ]]; then | ||
CHAIN="${ELEMENTS_MAINNET_CHAIN:-liquidv1}" | ||
else | ||
CHAIN="" | ||
fi | ||
|
||
if [[ "$CHAIN" ]]; then | ||
CONFIG_PREFIX="chain=${CHAIN}${NL}[${CHAIN}]" | ||
fi | ||
|
||
if [[ "$ELEMENTS_WALLETDIR" ]] && [[ "$CHAIN" ]]; then | ||
|
||
WALLETDIR="$ELEMENTS_WALLETDIR/${CHAIN}" | ||
mkdir -p "$WALLETDIR" | ||
[[ -f "${WALLETDIR}/db.log" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/db.log" "${WALLETDIR}/${CHAIN}/wallets/db.log" | ||
[[ -f "${WALLETDIR}/wallet.dat" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/wallet.dat" "${WALLETDIR}/${CHAIN}/wallets/wallet.dat" | ||
[[ -d "${WALLETDIR}/database" ]] && mkdir -p "${WALLETDIR}/${CHAIN}/wallets" && mv "${WALLETDIR}/database" "${WALLETDIR}/${CHAIN}/wallets/database" | ||
chown -R elements:elements "$WALLETDIR" | ||
CONFIG_PREFIX="${CONFIG_PREFIX}${NL}walletdir=${WALLETDIR}/${CHAIN}/wallets${NL}" | ||
WALLETFILE="${WALLETDIR}/${CHAIN}/wallets/wallet.dat" | ||
if ! [[ -f "${WALLETFILE}" ]]; then | ||
echo "The wallet does not exists, creating it at ${WALLETDIR}..." | ||
gosu elements elements-wallet "-datadir=${WALLETDIR}" "-wallet=" create | ||
fi | ||
fi | ||
|
||
cat <<-EOF > "$ELEMENTS_DATA/elements.conf" | ||
${CONFIG_PREFIX} | ||
printtoconsole=1 | ||
rpcallowip=::/0 | ||
${ELEMENTS_EXTRA_ARGS} | ||
EOF | ||
chown elements:elements "$ELEMENTS_DATA/elements.conf" | ||
|
||
if [[ "${ELEMENTS_TORCONTROL}" ]]; then | ||
# Because elementsd only accept torcontrol= host as an ip only, we resolve it here and add to config | ||
TOR_CONTROL_HOST=$(echo ${ELEMENTS_TORCONTROL} | cut -d ':' -f 1) | ||
TOR_CONTROL_PORT=$(echo ${ELEMENTS_TORCONTROL} | cut -d ':' -f 2) | ||
if [[ "$TOR_CONTROL_HOST" ]] && [[ "$TOR_CONTROL_PORT" ]]; then | ||
TOR_IP=$(getent hosts $TOR_CONTROL_HOST | cut -d ' ' -f 1) | ||
echo "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" >> "$ELEMENTS_DATA/elements.conf" | ||
echo "Added "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" to $ELEMENTS_DATA/elements.conf" | ||
else | ||
echo "Invalid ELEMENTS_TORCONTROL" | ||
fi | ||
fi | ||
|
||
# ensure correct ownership and linking of data directory | ||
# we do not update group ownership here, in case users want to mount | ||
# a host directory and still retain access to it | ||
chown -R elements "$ELEMENTS_DATA" | ||
ln -sfn "$ELEMENTS_DATA" /home/elements/.elements | ||
chown -h elements:elements /home/elements/.elements | ||
|
||
exec gosu elements "$@" | ||
else | ||
exec "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM debian:buster-slim as builder | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget | ||
|
||
ENV ELEMENTS_VERSION 23.2.1 | ||
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-x86_64-linux-gnu.tar.gz | ||
ENV ELEMENTS_SHA256 75b81d43e1fead0dacce5f4a27dbc10faf57e070a56633645e3f2fa3227b720a | ||
|
||
# install elements binaries | ||
RUN set -ex \ | ||
&& cd /tmp \ | ||
&& wget -qO elements.tar.gz "$ELEMaENTS_URL" \ | ||
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \ | ||
&& mkdir bin \ | ||
&& 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" \ | ||
&& cd bin \ | ||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64" \ | ||
&& echo "0b843df6d86e270c5b0f5cbd3c326a04e18f4b7f9b8457fa497b0454c4b138d7 gosu" | sha256sum -c - | ||
|
||
FROM debian:buster-slim | ||
COPY --from=builder "/tmp/bin" /usr/local/bin | ||
|
||
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements | ||
|
||
# create data directory | ||
ENV ELEMENTS_DATA /data | ||
RUN mkdir "$ELEMENTS_DATA" \ | ||
&& chown -R elements:elements "$ELEMENTS_DATA" \ | ||
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \ | ||
&& chown -h elements:elements /home/elements/.elements | ||
|
||
VOLUME /data | ||
|
||
COPY docker-entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["bash", "/entrypoint.sh"] | ||
|
||
EXPOSE 8332 8333 18332 18333 18443 18444 | ||
CMD ["elementsd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Use manifest image which support all architecture | ||
FROM debian:buster-slim as builder | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget | ||
|
||
ENV ELEMENTS_VERSION 23.2.1 | ||
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-arm-linux-gnueabihf.tar.gz | ||
ENV ELEMENTS_SHA256 9640e40685d25c7053a07ba5ad2319632a8d67bed5b2fbdc815163210b2bf0ff | ||
|
||
# install elements binaries | ||
RUN set -ex \ | ||
&& cd /tmp \ | ||
&& wget -qO elements.tar.gz "$ELEMENTS_URL" a\ | ||
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \ | ||
&& mkdir bin \ | ||
&& 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" \ | ||
&& cd bin \ | ||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-armhf" \ | ||
&& echo "171b4a2decc920de0dd4f49278d3e14712da5fa48de57c556f99bcdabe03552e gosu" | sha256sum -c - | ||
|
||
# Making sure the builder build an arm image despite being x64 | ||
FROM arm32v7/debian:buster-slim | ||
|
||
COPY --from=builder "/tmp/bin" /usr/local/bin | ||
#EnableQEMU COPY qemu-arm-static /usr/bin | ||
|
||
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements | ||
|
||
# create data directory | ||
ENV ELEMENTS_DATA /data | ||
RUN mkdir "$ELEMENTS_DATA" \ | ||
&& chown -R elements:elements "$ELEMENTS_DATA" \ | ||
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \ | ||
&& chown -h elements:elements /home/elements/.elements | ||
|
||
VOLUME /data | ||
|
||
COPY docker-entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["bash", "/entrypoint.sh"] | ||
|
||
EXPOSE 8332 8333 18332 18333 18443 18444 | ||
CMD ["elementsd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Use manifest image which support all architecture | ||
FROM debian:buster-slim as builder | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget | ||
|
||
ENV ELEMENTS_VERSION 23.2.1 | ||
ENV ELEMENTS_URL https://github.com/ElementsProject/elements/releases/download/elements-23.2.1/elements-23.2.1-aarch64-linux-gnu.tar.gz | ||
ENV ELEMENTS_SHA256 1c58616f3c0ca4907ed94974e875b07bd16c07989ec48708d5b4e1210de11304 | ||
|
||
# install elements binaries | ||
RUN set -ex \ | ||
&& cd /tmp \ | ||
&& wget -qO elements.tar.gz "$ELEMENTS_URL" \ | ||
&& echo "$ELEMENTS_SHA256 elements.tar.gz" | sha256sum -c - \ | ||
&& mkdir bin \ | ||
&& 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" \ | ||
&& cd bin \ | ||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-arm64" \ | ||
&& echo "5e279972a1c7adee65e3b5661788e8706594b458b7ce318fecbd392492cc4dbd gosu" | sha256sum -c - | ||
|
||
# Making sure the builder build an arm image despite being x64 | ||
FROM arm64v8/debian:buster-slim | ||
|
||
COPY --from=builder "/tmp/bin" /usr/local/bin | ||
#EnableQEMU COPY qemu-aarch64-static /usr/bin | ||
|
||
RUN chmod +x /usr/local/bin/gosu && groupadd -r elements && useradd -r -m -g elements elements | ||
|
||
# create data directory | ||
ENV ELEMENTS_DATA /data | ||
RUN mkdir "$ELEMENTS_DATA" \ | ||
&& chown -R elements:elements "$ELEMENTS_DATA" \ | ||
&& ln -sfn "$ELEMENTS_DATA" /home/elements/.elements \ | ||
&& chown -h elements:elements /home/elements/.elements | ||
a | ||
VOLUME /data | ||
|
||
COPY docker-entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["bash", "/entrypoint.sh"] | ||
|
||
EXPOSE 8332 8333 18332 18333 18443 18444 | ||
CMD ["elementsd"] |