add multi-arch support and build from shell script

This commit is contained in:
danielclough
2020-12-26 15:10:58 +01:00
parent f916662d90
commit 91b6717f0a
15 changed files with 426 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
FROM ubuntu
FROM ubuntu AS basebase
ENV BRANCH=master
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@@ -23,37 +23,35 @@ RUN apt-get update && apt-get install -yqq \
gperf \
wget \
jq \
bc
bc \
g++-aarch64-linux-gnu \
binutils-aarch64-linux-gnu
#
# Build Blackcoin More
#
RUN git clone -b $BRANCH https://github.com/CoinBlack/blackcoin-more.git
RUN (wget http://distfiles.gentoo.org/distfiles/db-6.2.38.tar.gz && \
tar -xvf db-6.2.38.tar.gz && \
cd db-6.2.38/build_unix && \
mkdir -p build && \
BDB_PREFIX=$(pwd)/build && \
../dist/configure --disable-shared -disable-replication --enable-cxx --with-pic --prefix=$BDB_PREFIX --with-gui=no --enable-glibc-back-compat --enable-reduce-exports --disable-tests --disable-bench --disable-gui-tests --disable-man && \
make install && \
cd ../.. && \
make install
# Build Blackcoin More for AMD64
FROM apt-install AS ubase-amd64
RUN git clone -b $BRANCH https://github.com/CoinBlack/blackcoin-more.git && \
cd blackcoin-more/ && ./autogen.sh && \
./configure CPPFLAGS="-I${BDB_PREFIX}/include/ -O2" LDFLAGS="-L${BDB_PREFIX}/lib/" --disable-tests --disable-bench --enable-reduce-exports && \
make -j4 && \
cd src/ && \
strip blackmore*)
#
# Prepare for minimal package
#
RUN cp /blackcoin-more/src/blackmored /usr/local/bin/ && \
cp /blackcoin-more/src/blackmore-cli /usr/local/bin/ && \
cp /blackcoin-more/contrib/blk /usr/local/bin/
WORKDIR /parts
RUN cp --parents /usr/local/bin/blk ./ && \
cp --parents /usr/local/bin/blackmored ./ && \
for i in `ldd /usr/local/bin/blackmored | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
@@ -63,3 +61,41 @@ RUN cp --parents /usr/local/bin/blk ./ && \
for i in `ldd /usr/bin/bc | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/jq --parents ./ && \
for i in `ldd /usr/bin/jq | grep -v linux-vdso.so.1 | grep -v libjq.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done
# Build Blackcoin More
FROM apt-install AS ubase-aarch64
RUN git clone -b $BRANCH https://github.com/CoinBlack/blackcoin-more.git
RUN (wget http://distfiles.gentoo.org/distfiles/db-6.2.38.tar.gz && \
tar -xvf db-6.2.38.tar.gz && \
cd db-6.2.38/build_unix && \
cd depends && \
make HOST=aarch64-linux-gnu -j4 && \
cd .. && \
./autogen.sh && \
./configure --prefix=$PWD/depends/aarch64-linux-gnu --enable-glibc-back-compat --enable-reduce-exports --disable-tests --disable-bench --disable-gui-tests --enable-upnp-default LDFLAGS=-static-libstdc++ CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" && \
make -j4 && \
make install && \
cd src/ && \
strip blackmore*)
# Prepare for minimal package
RUN cp /blackcoin-more/src/blackmored /usr/local/bin/ && \
cp /blackcoin-more/src/blackmore-cli /usr/local/bin/ && \
cp /blackcoin-more/contrib/blk /usr/local/bin/
WORKDIR /parts
RUN cp --parents /usr/local/bin/blk ./ && \
cp --parents /usr/local/bin/blackmored ./ && \
for i in `ldd /usr/local/bin/blackmored | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp --parents /usr/local/bin/blackmore-cli ./ && \
for i in `ldd /usr/local/bin/blackmore-cli | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/bc --parents ./ && \
for i in `ldd /usr/bin/bc | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/jq --parents ./ && \
for i in `ldd /usr/bin/jq | grep -v linux-vdso.so.1 | grep -v libjq.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done

View File

@@ -0,0 +1,3 @@
[Trash Info]
Path=contrib/docker/moreBuilder
DeletionDate=2020-12-26T06:00:23

21
Jenkinsfile vendored
View File

@@ -1,17 +1,10 @@
pipeline {
agent {
dockerfile {
filename 'contrib/docker/moreBuilder/Dockerfile.ubase'
args '--network=host'
agent { label 'master' }
stages {
stage('build') {
steps {
sh "contrib/docker/build.sh -o aarch64-linux-gnu blackcoinnl github CoinBlack env.GIT_LOCAL_BRANCH Etc/UTC"
}
}
}
}
stages {
stage('Build') {
steps {
sh 'blackmored -daemon'
}
}
}
}

View File

@@ -0,0 +1,51 @@
FROM ubuntu AS ubase
ENV BRANCH=master
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -yqq \
git \
make \
file \
autoconf \
automake \
libtool \
libevent-dev \
build-essential \
autotools-dev \
pkg-config \
bsdmainutils \
python3 \
libevent-dev \
libboost-all-dev \
libminiupnpc-dev \
libzmq3-dev \
libssl-dev \
gperf \
wget \
# blk commandline utility
jq \
bc \
# cross compile arm
g++-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf \
# cross compile aarch64
g++-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \
# cross compile macOS
curl \
librsvg2-bin \
libtiff-tools \
bsdmainutils \
cmake \
imagemagick \
libcap-dev \
libz-dev \
libbz2-dev \
python3-setuptools \
libtinfo5
FROM ubase AS ubase-base
RUN git clone -b $BRANCH https://github.com/CoinBlack/blackcoin-more.git

10
contrib/docker/README.md Executable file
View File

@@ -0,0 +1,10 @@
## To Build
#### Log in to [Docker Hub](https://hub.docker.com).
`docker login`
#### Build
`moreBuilder/build.sh`

View File

@@ -0,0 +1,25 @@
FROM ubase-base AS ubase-aarch64-linux-gnu
COPY aarch64-linux-gnu ./aarch64-linux-gnu
WORKDIR /blackcoin-more
RUN (git clean -xf && \
./autogen.sh && \
./configure --prefix=/aarch64-linux-gnu --enable-glibc-back-compat --enable-reduce-exports --disable-tests --disable-bench --disable-gui-tests --enable-upnp-default LDFLAGS=-static-libstdc++ && \
make -j4 && \
make install && \
cd src/ && \
/usr/bin/aarch64-linux-gnu-strip blackmore*)
RUN cp /blackcoin-more/src/blackmored /usr/local/bin/ && \
cp /blackcoin-more/src/blackmore-cli /usr/local/bin/ && \
cp /blackcoin-more/contrib/blk /usr/local/bin/
WORKDIR /aarch64-linux-gnu/parts
RUN cp --parents /usr/local/bin/blk ./ && \
cp --parents /usr/local/bin/blackmored ./ && \
for i in `ldd /usr/local/bin/blackmored | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp --parents /usr/local/bin/blackmore-cli ./ && \
for i in `ldd /usr/local/bin/blackmore-cli | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/bc --parents ./ && \
cp /usr/bin/jq --parents ./
WORKDIR /
RUN ls /blackcoin-more/src | grep blackmore && ls /usr/local/bin && ls /aarch64-linux-gnu/parts/usr

View File

@@ -0,0 +1,22 @@
FROM ubase-aarch64-linux-gnu AS ubuntu-aarch64-linux-gnu
# Collect dependencies
FROM ubuntu
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && \
apt-get -yqq upgrade && \
apt-get -yqq install \
libboost-all-dev \
libzmq3-dev \
libminiupnpc-dev
# Copy the binaries to our new container
COPY --from=ubase-aarch64-linux-gnu /blackcoin-more/src/blackmored /usr/local/bin
COPY --from=ubase-aarch64-linux-gnu /blackcoin-more/src/blackmore-cli /usr/local/bin
COPY --from=ubase-aarch64-linux-gnu /usr/bin/bc /usr/bin
COPY --from=ubase-aarch64-linux-gnu /usr/bin/jq /usr/bin
# Expose the port for the RPC interface
EXPOSE 15714/tcp

View File

@@ -0,0 +1,24 @@
FROM ubase-base AS ubase-arm-linux-gnueabihf
COPY arm-linux-gnueabihf ./arm-linux-gnueabihf
WORKDIR /blackcoin-more
RUN (git clean -xf && \
./autogen.sh && \
./configure --prefix=/arm-linux-gnueabihf --enable-glibc-back-compat --enable-reduce-exports --disable-tests --disable-bench --disable-gui-tests --enable-upnp-default LDFLAGS=-static-libstdc++ && \
make -j4 && \
make install && \
cd src/ && \
/usr/bin/arm-linux-gnueabihf-strip blackmore*)
RUN cp /blackcoin-more/src/blackmored /usr/local/bin/ && \
cp /blackcoin-more/src/blackmore-cli /usr/local/bin/ && \
cp /blackcoin-more/contrib/blk /usr/local/bin/
WORKDIR /arm-linux-gnueabihf/parts
RUN cp --parents /usr/local/bin/blk ./ && \
cp --parents /usr/local/bin/blackmored ./ && \
for i in `ldd /usr/local/bin/blackmored | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp --parents /usr/local/bin/blackmore-cli ./ && \
for i in `ldd /usr/local/bin/blackmore-cli | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/bc --parents ./ && \
cp /usr/bin/jq --parents ./
WORKDIR /

View File

@@ -0,0 +1,22 @@
FROM ubase-arm-linux-gnueabihf AS ubuntu-arm-linux-gnueabihf
# Collect dependencies
FROM ubuntu
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && \
apt-get -yqq upgrade && \
apt-get -yqq install \
libboost-all-dev \
libzmq3-dev \
libminiupnpc-dev
# Copy the binaries from to our new container
COPY --from=ubase-arm-linux-gnueabihf /blackcoin-more/src/blackmored /usr/local/bin
COPY --from=ubase-arm-linux-gnueabihf /blackcoin-more/src/blackmore-cli /usr/local/bin
COPY --from=ubase-arm-linux-gnueabihf /usr/bin/bc /usr/bin
COPY --from=ubase-arm-linux-gnueabihf /usr/bin/jq /usr/bin
# Expose the port for the RPC interface
EXPOSE 15714/tcp

166
contrib/docker/build.sh Executable file
View File

@@ -0,0 +1,166 @@
#!/bin/bash
BASE_DIR=$(dirname $(realpath $0 ))
Alist="\n
\t \t \t \t aarch64-linux-gnu \t (eg. Raspi4 with Ubuntu) \n
\t \t \t \t arm-linux-gnueabihf \t (eg. Other Raspi) \n
\t \t \t \t x86_64-linux-gnu \t (aka. Linux AMD64) \n
\t \t \t \t all \t (only works in option mode) \n
"
usage="Usage: \n
\t option mode: \t \`build.sh -o <architecture> <DockerHub> <HubLab> <GitAccount> <branch> <timezone>\` \n
\t interactive: \t \`build.sh -i\` \n
\t \t \t help: \t \`build.sh -h\` \n
\n Architectures: ${Alist} \n
"
h1="<architecture> \t Choose your architecture. ${Alist}"
h2="<DockerHub> \t \t Enter your Docker Hub Account name."
h3="<HubLab> \t \t \t Enter \"github\" or \"gitlab\"."
h4="<GitAccount> \t Enter the git account name. (eg. \"CoinBlack\" on GitHub, or \"blackcoin\" on GitLab)"
h5="<branch> \t \t \t Enter the branch name. (eg. master)"
h6="<timezone> \t \t Enter your timezone. (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)"
help=" \n
\t The defaults in interactive mode, written in for option mode: \n
build.sh -o x86_64-linux-gnu blackcoinnl github CoinBlack v2.13.2.7 America/Los_Angeles \n
\n $h1 \n
\n $h2 \n
\n $h3 \n
\n $h4 \n
\n $h5 \n
\n $h6 \n
"
case $1 in
-h)
echo -e ${help}
;;
-i|-o)
# Questions for Interactive Mode
defaultARCH=${2:-x86_64-linux-gnu}
defaultDockerHub=${3:-blackcoinnl}
defaultHubLab=${4:-github}
defaultRepo=${5:-CoinBlack}
defaultBranch=${6:-v2.13.2.7}
defaultTimezone=${7:-America/Los_Angeles}
if [[ $1 == -i ]]; then
echo -e ${Alist}
read -p "For what architecture would you like to build? ($defaultARCH): " architecture
read -p "What is your DockerHub Account Name? ($defaultDockerHub): " DockerHub
read -p "Github or Gitlab? ($defaultHubLab): " HubLab
read -p "What is your GitAccount name? ($defaultRepo): " GitAccount
read -p "What branch/version? ($defaultBranch): " branch
read -p "What is your timezone? (${defaultTimezone}): " timezone
echo "Architecture: ${architecture}"
echo "DockerHub Account: ${DockerHub}"
echo "Git Account: ${HubLab}.com/${GitAccount} ${branch}"
echo "Timezone: ${timezone}"
else
echo "Option Mode!"
echo "Architecture: $2"
echo "DockerHub Account: $3"
echo "Git Account: https://${4}.com/${5} ${6}"
echo "Timezone: ${7}"
fi
# Architecture
architecture=${architecture:-${defaultARCH}}
if [[ ${architecture} == all ]]; then
bash ${BASE_DIR}/build.sh -o aarch64-linux-gnu $3 $4 $5 $6 $7
bash ${BASE_DIR}/build.sh -o arm-linux-gnueabihf $3 $4 $5 $6 $7
bash ${BASE_DIR}/build.sh -o x86_64-linux-gnu $3 $4 $5 $6 $7
exit 0
else
[[ ${architecture} != ${defaultARCH} ]] && sed -i "s/-x86_64-linux-gnu/-${architecture}/" $0
# Download Dependencies
if [[ -f ${BASE_DIR}/depends-${architecture}.tar.xz ]]; then
echo "Dependencies exist!"
else
wget -qO ${BASE_DIR}/depends-${architecture}.tar.xz https://admin.blackcoin.nl/static/depends-${architecture}.tar.xz
case $architecture in
aarch64-linux-gnu)
checkSUM=`echo "f6f1b099d876db90396d0d56eb5b3f366f14c90e077524e2b10bfdaaa1aa5805 ${BASE_DIR}/depends-${architecture}.tar.xz" | sha256sum --check | awk '{print $2}' 2> /dev/null`
[[ "${checkSUM}" == "OK" ]] && echo "The sha256sum is OK! You will need sudo to untar the dependencies." && sudo tar xJf ${BASE_DIR}/depends-${architecture}.tar.xz -C ${BASE_DIR} \
|| (>&2 echo 'SHASUM FAIL'; exit 1)
;;
arm-linux-gnueabihf)
checkSUM=`echo "339c1159adcccecb45155b316f1f5772009b92acb8cfed29464dd7f09775fb79 ${BASE_DIR}/depends-${architecture}.tar.xz" | sha256sum --check | awk '{print $2}' 2> /dev/null`
[[ "${checkSUM}" == "OK" ]] && echo "The sha256sum is OK! You will need sudo to untar the dependencies." && sudo tar xJf ${BASE_DIR}/depends-${architecture}.tar.xz -C ${BASE_DIR} \
|| (>&2 echo 'SHASUM FAIL'; exit 1)
;;
x86_64-linux-gnu)
checkSUM=`echo "eed063b26f4c4e0fa35dc085fe09bafd4251cffa76cdabb26bf43077da03b84e ${BASE_DIR}/depends-${architecture}.tar.xz" | sha256sum --check | awk '{print $2}' 2> /dev/null`
[[ "${checkSUM}" == "OK" ]] && echo "The sha256sum is OK! You will need sudo to untar the dependencies." && sudo tar xJf ${BASE_DIR}/depends-${architecture}.tar.xz -C ${BASE_DIR} \
|| (>&2 echo 'SHASUM FAIL'; exit 1)
;;
esac
echo -e "
Dependencies SHA256SUM GOOD!
"
fi
# DockerHub Account
DockerHub=${DockerHub:-${defaultDockerHub}}
[[ $DockerHub != ${defaultDockerHub} ]] && sed -i "s/blackcoinnl/${DockerHub}/" $0
# Git Account
HubLab=${HubLab:-${defaultHubLab}}
[[ $HubLab != $defaultHubLab ]] && sed -i "s|github|${HubLab}|" ${BASE_DIR}/Dockerfile.ubase && sed -i "s|github|${HubLab}|" $0
GitAccount=${GitAccount:-${defaultRepo}}
[[ ${GitAccount} != ${defaultRepo} ]] && sed -i "s|CoinBlack|$GitAccount|" ${BASE_DIR}/Dockerfile.ubase && sed -i "s|CoinBlack|$GitAccount|" $0
# branch
branch=${branch:-${defaultBranch}}
[[ ${branch} != ${defaultBranch} ]] && sed -i "s|ENV branch=v2.13.2.7|ENV branch=${branch}|" ${BASE_DIR}/Dockerfile.ubase && sed -i "s|v2.13.2.7|${branch}|" $0
# timezone
timezone=${timezone:-${defaultTimezone}}
[[ ${timezone} != ${defaultTimezone} ]] && sed -i "s|America/Los_Angeles|${timezone}|" ${BASE_DIR}/Dockerfile.ubase && \
sed -i "s|America/Los_Angeles|${timezone}|" ${BASE_DIR}/Dockerfile.ubuntu && sed -i "s|America/Los_Angeles|${timezone}|" $0
# build ubase-base
Dockerfile="${BASE_DIR}/Dockerfile.ubase-base"
docker build -t ubase-base --network=host - < ${Dockerfile}
# build ubase
ubase="ubase-${architecture}"
Dockerfile="${BASE_DIR}/${architecture}/Dockerfile.${ubase}"
docker build ./${architecture} -t ${ubase} --network=host -f ${Dockerfile}
# build ubuntu
ubuntu="ubuntu-${architecture}"
Dockerfile="${BASE_DIR}/${architecture}/Dockerfile.${ubuntu}"
docker build -t ${ubuntu} - --network=host < ${Dockerfile}
docker image tag ${ubuntu} ${DockerHub}/blackcoin-more-ubuntu-${architecture}:latest
# build minimal
minimal="minimal-${architecture}"
docker run -itd --network=host --name ${ubase} ${ubase} bash
docker cp ${ubase}:${architecture}/parts ${architecture}/parts
cd ${BASE_DIR}/${architecture}
tar -C parts -c . | docker import - ${minimal}
docker container rm -f ${ubase}
docker tag ${minimal} ${DockerHub}/blackcoin-more-minimal-${architecture}:latest
fi
;;
*)
echo -e ${usage}
;;
esac

View File

@@ -0,0 +1,24 @@
FROM ubase-base AS ubase-x86_64-linux-gnu
COPY x86_64-linux-gnu ./x86_64-linux-gnu
WORKDIR /blackcoin-more
RUN (git clean -xf && \
./autogen.sh && \
./configure --prefix=/x86_64-linux-gnu --enable-glibc-back-compat --enable-reduce-exports --disable-tests --disable-bench --disable-gui-tests --enable-upnp-default LDFLAGS=-static-libstdc++ && \
make -j4 && \
make install && \
cd src/ && \
/usr/bin/strip blackmore*)
RUN cp /blackcoin-more/src/blackmored /usr/local/bin/ && \
cp /blackcoin-more/src/blackmore-cli /usr/local/bin/ && \
cp /blackcoin-more/contrib/blk /usr/local/bin/
WORKDIR /x86_64-linux-gnu/parts
RUN cp --parents /usr/local/bin/blk ./ && \
cp --parents /usr/local/bin/blackmored ./ && \
for i in `ldd /usr/local/bin/blackmored | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp --parents /usr/local/bin/blackmore-cli ./ && \
for i in `ldd /usr/local/bin/blackmore-cli | grep -v linux-vdso.so.1 | awk {' if ( $3 == "") print $1; else print $3 '}`; do cp --parents $i ./; done && \
cp /usr/bin/bc --parents ./ && \
cp /usr/bin/jq --parents ./
WORKDIR /

View File

@@ -0,0 +1,23 @@
FROM ubase-x86_64-linux-gnu AS ubuntu-x86_64-linux-gnu
# Collect dependencies
FROM ubuntu
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && \
apt-get -yqq upgrade && \
apt-get -yqq install \
libboost-all-dev \
libzmq3-dev \
libminiupnpc-dev
# Copy the binaries to our new container
COPY --from=ubase-x86_64-linux-gnu /blackcoin-more/src/blackmored /usr/local/bin
COPY --from=ubase-x86_64-linux-gnu /blackcoin-more/src/blackmore-cli /usr/local/bin
COPY --from=ubase-x86_64-linux-gnu /usr/bin/bc /usr/bin
COPY --from=ubase-x86_64-linux-gnu /usr/bin/jq /usr/bin
# Expose the port for the RPC interface
EXPOSE 15714/tcp