From cf9878ae7a8cbd08852cf7597d53796a3e22ade1 Mon Sep 17 00:00:00 2001 From: Wangzihao18 <55722482+Wangzihao18@users.noreply.github.com> Date: Wed, 27 Nov 2019 18:14:00 +0800 Subject: [PATCH] feat(build): add support for building on arm and x86 (#294) Signed-off-by: wangzihao --- build_image.sh | 17 +++++++++++++++-- docker/Dockerfile | 6 +++--- docker/Dockerfile.arm64 | 31 +++++++++++++++++++++++++++++++ docker/entrypoint-istgtimage.sh | 3 ++- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 docker/Dockerfile.arm64 diff --git a/build_image.sh b/build_image.sh index 1211c7eb..ea04e147 100755 --- a/build_image.sh +++ b/build_image.sh @@ -2,6 +2,10 @@ set -e pwd + +# Determine the arch/os we're building for +ARCH=$(uname -m) + make clean bash autogen.sh ./configure --enable-replication @@ -9,7 +13,16 @@ make clean make BUILD_DATE=$(date +'%Y%m%d%H%M%S') -REPO_NAME="openebs/cstor-istgt" +if [ "${ARCH}" = "x86_64" ]; then + REPO_NAME="openebs/cstor-istgt" + DOCKERFILE="Dockerfile" +elif [ "${ARCH}" = "aarch64" ]; then + REPO_NAME="openebs/cstor-istgt-arm64" + DOCKERFILE="Dockerfile.arm64" +else + echo "Unusable architecture: ${ARCH}" + exit 1 +fi echo "Build image ${REPO_NAME}:ci with BUILD_DATE=${BUILD_DATE}" @@ -22,7 +35,7 @@ sudo docker version sudo docker build --help cd docker && \ - sudo docker build -f Dockerfile -t ${REPO_NAME}:ci --build-arg BUILD_DATE=${BUILD_DATE} . && \ + sudo docker build -f ${DOCKERFILE} -t ${REPO_NAME}:ci --build-arg BUILD_DATE=${BUILD_DATE} . && \ IMAGE_REPO=${REPO_NAME} ./push && \ cd .. diff --git a/docker/Dockerfile b/docker/Dockerfile index bf88396d..a3c47b47 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,10 +20,10 @@ COPY entrypoint-istgtimage.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint-istgtimage.sh ARG BUILD_DATE -LABEL org.label-schema.name="cstor" -LABEL org.label-schema.description="OpenEBS cstor" +LABEL org.label-schema.name="istgt" +LABEL org.label-schema.description="OpenEBS istgt" LABEL org.label-schema.url="http://www.openebs.io/" -LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor" +LABEL org.label-schema.vcs-url="https://github.com/openebs/istgt" LABEL org.label-schema.schema-version="1.0" LABEL org.label-schema.build-date=$BUILD_DATE diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 new file mode 100644 index 00000000..87c78e8a --- /dev/null +++ b/docker/Dockerfile.arm64 @@ -0,0 +1,31 @@ +# +# This Dockerfile builds cstor istgt container running istgt from istgt base image +# + +FROM arm64v8/ubuntu:18.04 +RUN apt-get update; exit 0 +RUN apt-get -y install rsyslog +RUN apt-get -y install curl tcpdump dnsutils net-tools iputils-ping gdb +RUN apt-get -y install apt-utils libssl-dev libjson-c-dev libjemalloc-dev +RUN apt-get -y install apt-file && apt-file update + +RUN mkdir -p /usr/local/etc/bkpistgt +RUN mkdir -p /usr/local/etc/istgt +COPY istgt istgtcontrol /usr/local/bin/ +COPY istgt.conf istgtcontrol.conf /usr/local/etc/bkpistgt/ +RUN touch /usr/local/etc/bkpistgt/auth.conf +RUN touch /usr/local/etc/bkpistgt/logfile + +COPY entrypoint-istgtimage.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/entrypoint-istgtimage.sh + +ARG BUILD_DATE +LABEL org.label-schema.name="istgt" +LABEL org.label-schema.description="OpenEBS istgt" +LABEL org.label-schema.url="http://www.openebs.io/" +LABEL org.label-schema.vcs-url="https://github.com/openebs/istgt" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.build-date=$BUILD_DATE + +ENTRYPOINT entrypoint-istgtimage.sh +EXPOSE 3260 6060 diff --git a/docker/entrypoint-istgtimage.sh b/docker/entrypoint-istgtimage.sh index c6547f59..1411be08 100644 --- a/docker/entrypoint-istgtimage.sh +++ b/docker/entrypoint-istgtimage.sh @@ -20,6 +20,7 @@ touch /usr/local/etc/istgt/logfile export externalIP=0.0.0.0 service rsyslog start -export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so +ARCH=$(uname -m) +export LD_PRELOAD=/usr/lib/${ARCH}-linux-gnu/libjemalloc.so exec /usr/local/bin/istgt