Skip to content

Commit

Permalink
Merge pull request #35 from yohanchatelain/master
Browse files Browse the repository at this point in the history
Add bash script to build a dockerfile and replace libmath by fuzzy-libmath
  • Loading branch information
gkiar authored Jun 16, 2021
2 parents 78cfc4d + 28ac4de commit 4484855
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/base/Dockerfile.ubuntu20.04-0-lapack-libmath
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update -qqq &&\
make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget \
curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev wget fort77 gfortran cmake lzma-dev &&\
xz-utils tk-dev wget fort77 gfortran cmake lzma-dev liblzma-dev &&\
rm -rf /var/lib/apt/lists/ &&\
mkdir -p /opt/build/

Expand Down
50 changes: 50 additions & 0 deletions docker/resources/build_fuzzy_libmath_dockerfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

DOCKERFILE=Dockerfile.mcalibmath
FUZZY_IMAGE_DEFAULT=verificarlo/fuzzy:v0.4.1-lapack

generate_docker() {

cat > ${DOCKERFILE} <<HERE
# Base image
FROM ${1}
# Copy fuzzy environment from fuzzy image
RUN mkdir -p /opt/mca-libmath
COPY --from=${2} /opt/mca-libmath/libmath.so /opt/mca-libmath/
COPY --from=${2} /usr/local/lib/libinterflop* /usr/local/lib/
# Set environment variables
ENV VFC_BACKENDS 'libinterflop_mca.so --precision-binary32=24 --precision-binary64=53 --mode=mca'
ENV LD_PRELOAD '/opt/mca-libmath/libmath.so'
HERE

}

build_docker() {
docker build -f ${DOCKERFILE} -t ${1} .
}

if [[ $# < 2 ]]
then
echo "usage: ./build_fuzzy_libmath_dockerfile.sh <DOCKER_IMAGE> <TAG> [FUZZY_IMAGE]"
echo " <DOCKER_IMAGE>: Name of the base docker image to build"
echo " <TAG>: Tag of the new image to build"
echo " [FUZZY_IMAGE]: Name of the fuzzy image to copy from (optional)"
exit 1
elif [[ $# == 2 ]]
then
BASE_IMAGE=$1
TAG=$2
FUZZY_IMAGE=$FUZZY_IMAGE_DEFAULT
elif [[ $# == 3 ]]
then
BASE_IMAGE=$1
TAG=$2
FUZZY_IMAGE=$3
fi

echo "Build fuzzy-libmath (from ${FUZZY_IMAGE}) for ${BASEIMAGE} as ${TAG}"
generate_docker $BASEIMAGE $FUZZY_IMAGE
build_docker $TAG

0 comments on commit 4484855

Please sign in to comment.