Skip to content

Instantly share code, notes, and snippets.

@snoby
Created September 18, 2023 17:53
Show Gist options
  • Save snoby/f3ed53e2d353b6797a0a43b7d8a613ac to your computer and use it in GitHub Desktop.
Save snoby/f3ed53e2d353b6797a0a43b7d8a613ac to your computer and use it in GitHub Desktop.
FROM ubuntu:22.04 AS base
RUN apt update && DEBIAN_FRONTEND=nointeractive apt install --no-install-recommends -y \
libcurl4-openssl-dev \
wget bash net-tools \
libevent-dev \
uthash-dev \
libboost-chrono-dev \
libboost-filesystem-dev \
libboost-test-dev \
libboost-thread-dev \
libevent-dev \
libminiupnpc-dev \
libssl-dev \
libzmq3-dev \
libdb++-dev \
libboost-program-options-dev \
wget
#Install runtime dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -yqq && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bash net-tools libminiupnpc17 \
libevent-2.1 libevent-pthreads-2.1 \
libdb4.8 libdb4.8++ \
libboost-system-dev libboost-filesystem-dev libboost-chrono-dev \
libboost-program-options-dev libboost-test-dev libboost-thread-dev \
libzmq5 && \
apt-get clean
FROM base AS build
#Install build dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bash net-tools build-essential libtool autotools-dev automake git \
pkg-config libssl-dev libevent-dev bsdmainutils python3 \
libboost-system-dev libboost-filesystem-dev libboost-chrono-dev \
libboost-program-options-dev libboost-test-dev libboost-thread-dev \
libzmq3-dev libminiupnpc-dev && \
apt-get clean
#
# have to build libdb4.8
#
RUN mkdir /tmp/libdb
WORKDIR /tmp/libdb
ADD http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz db-4.8.30.NC.tgz
RUN tar zxvf db-4.8.30.NC.tgz
# problem with the source and new compilers
RUN sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' db-4.8.30.NC/dbinc/atomic.h
WORKDIR /tmp/libdb/db-4.8.30.NC/build_unix/
RUN ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/usr/
RUN make -j
RUN make install
ENV VER="1.0.0"
ENV MINOR="0"
ADD https://gitlab.com/cloreai-public/blockchain/-/archive/${VER}/blockchain-${VER}.tar.gz /tmp/release.tgz
RUN mkdir /tmp/build
RUN tar -zxvf /tmp/release.tgz -C /tmp/build
RUN ls -lah /tmp/build/blockchain-1.0.0/
WORKDIR /tmp/build/blockchain-1.0.0
RUN chmod +x ./autogen.sh && chmod +x share/genbuild.sh && ./autogen.sh && ./configure --disable-tests --with-gui=no && make -j
from base as final
#Add our service account user
RUN useradd -ms /bin/bash clore && \
mkdir /var/lib/clore && \
chown clore:clore /var/lib/clore && \
ln -s /var/lib/clore /home/clore/.clore && \
chown -h clore:clore /home/clore/.clore
COPY --from=build /tmp/build/blockchain-1.0.0/src/clore_blockchaind /usr/local/bin/
COPY --from=build /tmp/build/blockchain-1.0.0/src/clore-cli /usr/local/bin/
VOLUME /var/lib/clore
# The home directory needs to be a volume mount
#
VOLUME ["/var/lib/clore/","/data/", "/etc/clore/clore.conf"]
# public port
EXPOSE 8788/tcp
# private RPC port
EXPOSE 9766/tcp
WORKDIR /home/clore
USER clore
ENTRYPOINT ["clore_blockchaind","-datadir=/var/lib/clore", "-printtoconsole -onlynet=ipv4"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment