- Shell script Select all
cd $HOME
mkdir -p my-quantlib
cd my-quantlib
# get helloworld.ipynb
wget https://raw.githubusercontent.com/lballabio/dockerfiles/master/quantlib-jupyter/Hello%20world.ipynb
cat >$HOME/my-quantlib/Dockerfile_ql_armv7_1.21 <<'HEREEOF'
# Dockerfile_ql_armv7_1.21
# docker buildx build --platform linux/arm/v7 -f Dockerfile_ql_armv7_1.21 -t armv7/quantlib:1.21 .
# Build Quantlib libraries for armv7 in arm64/amd64 host
ARG tag=latest
FROM arm32v7/ubuntu:18.04
LABEL Description="Provide a building environment where the QuantLib Python jupyter-notebook"
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential wget libbz2-dev vim git
ENV boost_version=1.67.0
ENV boost_dir=boost_1_67_0
# Build boost
RUN echo 'Building boost ...'
RUN wget --no-check-certificate https://boostorg.jfrog.i
o/artifactory/main/release/${boost_version}/source/${boo
st_dir}.tar.gz \
&& tar xfz ${boost_dir}.tar.gz \
&& rm ${boost_dir}.tar.gz \
&& cd ${boost_dir} \
&& ./bootstrap.sh \
&& ./b2 --without-python --prefix=/usr -j 4 link=shared runtime-link=shared install \
&& ./b2 --prefix=/Staging/usr install \
&& cd .. && rm -rf ${boost_dir} && ldconfig
# Build Quantlib C++
RUN echo 'Building Quantlib C++ ...'
ENV quantlib_version=1.21
RUN wget https://github.com/lballabio/QuantLib/releases/download/QuantLib-v${quantlib_version}/QuantLib-${quantlib_version}.tar.gz \
&& tar xfz QuantLib-${quantlib_version}.tar.gz \
&& rm QuantLib-${quantlib_version}.tar.gz \
&& cd QuantLib-${quantlib_version} \
&& ./configure --prefix=/usr --disable-static CXXFLAGS=-O3 \
&& make -j 4 && make install \
&& make DESTDIR=/Staging install \
&& make clean \
&& cd .. && ldconfig
# && cd .. && rm -rf QuantLib-${quantlib_version} && ldconfig
# Build Quantlib-Python
RUN echo 'Build Quantlib-Python ...'
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y swig python3 python3-pip python-dev libgomp1
# Build Quantlib for Python3
RUN echo 'Install Quantlib Python'
ENV quantlib_swig_version=1.21
RUN wget https://github.com/lballabio/QuantLib-SWIG/releases/download/QuantLib-SWIG-v${quantlib_swig_version}/QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& tar xfz QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& rm QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& cd QuantLib-SWIG-${quantlib_swig_version} \
&& ./configure CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" PYTHON=/usr/bin/python3 \
&& make -C Python && make -C Python check && make -C Python install \
&& cd .. && rm -rf QuantLib-SWIG-${quantlib_swig_version} && ldconfig
# Build jupyter-notebook server
RUN python3 -c "print('\033[91m Building jupyter-notebook server ... \033[0m')"
RUN pip3 install --no-cache-dir jupyter jupyterlab matplotlib numpy scipy pandas ipywidgets RISE
RUN jupyter-nbextension install rise --py --sys-prefix
RUN jupyter-nbextension install widgetsnbextension --py --sys-prefix \
&& jupyter-nbextension enable widgetsnbextension --py --sys-prefix
# Build Quantlib for Python2
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python \
&& apt-get clean
RUN wget https://bootstrap.pypa.io/2.7/get-pip.py \
&& python2 get-pip.py \
&& rm get-pip.py
RUN wget https://dl.bintray.com/quantlib/releases/QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& tar xfz QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& rm QuantLib-SWIG-${quantlib_swig_version}.tar.gz \
&& cd QuantLib-SWIG-${quantlib_swig_version} \
&& ./configure CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" \
&& make -C Python && make -C Python check && make -C Python install \
&& cd .. && rm -rf QuantLib-SWIG-${quantlib_swig_version} && ldconfig
RUN pip2 install --no-cache-dir numpy
EXPOSE 8888
RUN mkdir /notebooks
VOLUME /notebooks
COPY *.ipynb /notebooks/
# Starting jupyter-notebook server
RUN python3 -c "print('\033[92m Starting jupyter-notebook server at port 8888 \033[0m')"
CMD jupyter notebook --no-browser --allow-root --ip=0.0.0.0 --port=8888 --notebook-dir=/notebooks
HEREEOF
# build and load image (after experimental feature of Docker Desktop is enabled
docker buildx build --platform linux/arm/v7 --memory="8g" --output "type=docker,push=false,dest=armv7_ql.tar" -f Dockerfile_ql_armv7_1.21 -t armv7/quantlib:1.21 .
docker load < armv7_ql.tar
# run image
docker run --platform linux/arm/v7 -d -p 8888:8888 --name myquantlibarmv7testing armv7/quantlib:1.21
# list the token of the jupyter-notebook server
docker container exec -it myquantlibarmv7testing jupyter notebook list
If using WSL2 docker CLI in Linux, should enable the experimental feature first.
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx inspect --bootstrap
docker buildx build --platform linux/arm/v7 --memory="8g" --output "type=docker,push=false,dest=armv7_ql.tar" -f Dockerfile_ql_armv7_1.21 -t armv7/quantlib:1.21 .
No comments:
Post a Comment