Skip to content

Commit

Permalink
feat(build): add support for building on arm and x86 (#294)
Browse files Browse the repository at this point in the history
Signed-off-by: wangzihao <[email protected]>
  • Loading branch information
wangzihao3 authored and vishnuitta committed Nov 27, 2019
1 parent c3fa155 commit cf9878a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
17 changes: 15 additions & 2 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@
set -e

pwd

# Determine the arch/os we're building for
ARCH=$(uname -m)

make clean
bash autogen.sh
./configure --enable-replication
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}"

Expand All @@ -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 ..

Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 31 additions & 0 deletions docker/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion docker/entrypoint-istgtimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cf9878a

Please sign in to comment.