Skip to content

Instantly share code, notes, and snippets.

@hoangphuchieu
Created April 12, 2021 10:13
Show Gist options
  • Save hoangphuchieu/8ccbba61413bf99b5e8f3de841fc09c3 to your computer and use it in GitHub Desktop.
Save hoangphuchieu/8ccbba61413bf99b5e8f3de841fc09c3 to your computer and use it in GitHub Desktop.
Docker containers build and run for Litecoin MWEB
#!/bin/sh
set -e
if [ $(echo "$1" | cut -c1) = "-" ]; then
echo "$0: assuming arguments for litecoind"
set -- litecoind "$@"
fi
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "litecoind" ]; then
mkdir -p "$LITECOIN_DATA"
chmod 770 "$LITECOIN_DATA" || echo "Could not chmod $LITECOIN_DATA (may not have appropriate permissions)"
chown -R litecoin "$LITECOIN_DATA" || echo "Could not chown $LITECOIN_DATA (may not have appropriate permissions)"
echo "$0: setting data directory to $LITECOIN_DATA"
set -- "$@" -datadir="$LITECOIN_DATA"
fi
if [ "$(id -u)" = "0" ] && ([ "$1" = "litecoind" ] || [ "$1" = "litecoin-cli" ] || [ "$1" = "litecoin-tx" ]); then
set -- gosu litecoin "$@"
fi
exec "$@"
FROM ubuntu:18.04 as build
RUN apt update && \
apt install -y build-essential pkg-config \
tar zip unzip \
wget curl \
git
FROM build as cmake
RUN apt install -y libssl-dev
ENV CMAKE_VERSIONN=3.20.1
RUN git clone https://github.com/Kitware/CMake.git --branch v${CMAKE_VERSIONN} --single-branch cmake-${CMAKE_VERSIONN}
WORKDIR /cmake-${CMAKE_VERSIONN}
RUN ./bootstrap
RUN make && make install && \
cmake --version | grep "${CMAKE_VERSIONN}"
FROM build as libmw
RUN apt install -y gcc-8 g++-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
COPY --from=cmake /usr/local /usr/local
RUN git clone https://github.com/ltc-mweb/libmw.git --recursive
WORKDIR /libmw/vcpkg/vcpkg
RUN ./bootstrap-vcpkg.sh
RUN ./vcpkg install --triplet x64-linux @../packages.txt
WORKDIR /libmw
RUN mkdir -p build
WORKDIR /libmw/build
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \
cmake --build . --target install
FROM build as ltc-mweb
RUN apt install -y libtool autotools-dev automake bsdmainutils python3
RUN apt install -y libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev
COPY --from=libmw /usr/local/include/libmw /usr/local/include/libmw
COPY --from=libmw /usr/local/lib/libmw* /usr/local/lib/
# ENV LITECOIN_VERSION=0.18.1
ENV LITECOIN_PREFIX=/opt/litecoin-mweb
RUN git clone https://github.com/ltc-mweb/litecoin.git ltc-mweb
WORKDIR /ltc-mweb
# Build Berkeley DB 4.8 for Wallet support
RUN ./contrib/install_db4.sh 'pwd'
# Build Litecoin MWEB with options
RUN ./autogen.sh
RUN ./configure \
# --disable-wallet \
BDB_LIBS="-L/db4/lib -ldb_cxx-4.8" BDB_CFLAGS="-I/db4/include" \
--prefix=${LITECOIN_PREFIX} \
--mandir=/usr/share/man \
--disable-tests \
--disable-bench \
--disable-ccache \
--without-gui \
--without-miniupnpc
RUN make -j4 && make install
FROM ubuntu:18.04 as binary
COPY --from=libmw /usr/local/include/libmw /usr/local/include/libmw
COPY --from=libmw /usr/local/lib/libmw* /usr/local/lib/
RUN useradd -r litecoin
RUN apt update && \
apt install -y curl gnupg && \
apt install -y libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev && \
apt clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN set -ex && \
for key in \
B42F6819007F00F88E364FD4036A9C25BF357DD4 \
# FE3348877809386C \
; do \
gpg --no-tty --keyserver pgp.mit.edu --recv-keys "$key" || \
gpg --no-tty --keyserver keyserver.pgp.com --recv-keys "$key" || \
gpg --no-tty --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --no-tty --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done
ENV GOSU_VERSION=1.10
RUN curl -o /usr/local/bin/gosu -fSL https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture) && \
curl -o /usr/local/bin/gosu.asc -fSL https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture).asc && \
gpg --verify /usr/local/bin/gosu.asc && \
rm /usr/local/bin/gosu.asc && \
chmod +x /usr/local/bin/gosu
# ENV LITECOIN_VERSION=0.18.1
ENV LITECOIN_PREFIX=/opt/litecoin-mweb
ENV LITECOIN_DATA=/home/litecoin/.litecoin-mweb
ENV PATH=${LITECOIN_PREFIX}/bin:$PATH
# RUN curl -SLO https://download.litecoin.org/litecoin-${LITECOIN_VERSION}/linux/litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz && \
# curl -SLO https://download.litecoin.org/litecoin-${LITECOIN_VERSION}/linux/litecoin-${LITECOIN_VERSION}-linux-signatures.asc && \
# gpg --verify litecoin-${LITECOIN_VERSION}-linux-signatures.asc && \
# grep $(sha256sum litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz | awk '{ print $1 }') litecoin-${LITECOIN_VERSION}-linux-signatures.asc && \
# tar --strip=2 -xzf *.tar.gz -C /usr/local/bin && \
# rm *.tar.gz
COPY --from=ltc-mweb ${LITECOIN_PREFIX} ${LITECOIN_PREFIX}
ADD docker-entrypoint.sh /entrypoint.sh
VOLUME ["${LITECOIN_DATA}"]
EXPOSE 9332 9333 19332 19333 19444
ENTRYPOINT ["/entrypoint.sh"]
CMD ["litecoind"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment