Docker Buildx feature - does not cache - docker

I'm trying to build a multi-arch docker image using the buildx experimental feature. The problem I face is that whenever I do a "make" or a "make install" docker does not cache that layer.
I'm using different cmake commands depending on the arch.
What am I missing? Is what I am trying to achieve posible or should I just make multiple dockerfiles?
FROM ubuntu:18.04 as builder
#RUN add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
RUN set -ex && \
apt update && apt upgrade -y && \
apt install -y build-essential cmake pkg-config && \
apt install -y libjpeg-dev libtiff5-dev libpng-dev && \
apt install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev && \
apt install -y libxvidcore-dev libx264-dev && \
apt install -y libfontconfig1-dev libcairo2-dev && \
apt install -y libgdk-pixbuf2.0-dev libpango1.0-dev && \
apt install -y libgtk2.0-dev libgtk-3-dev && \
apt install -y libatlas-base-dev gfortran && \
apt install -y libhdf5-dev libhdf5-serial-dev && \
apt install -y python3.7 python3.7-dev && \
apt install -y wget unzip git
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py && python3 get-pip.py
RUN rm -rf ~/.cache/pip
RUN python3 -m pip install --upgrade setuptools
RUN python3.7 get-pip.py
RUN python3.7 -m pip install --upgrade setuptools
RUN python3.7 --version
RUN python3 --version
#RUN git clone https://github.com/jasperproject/jasper-client.git jasper && \
# chmod +x jasper/jasper.py && \
# python3.7 -m pip install -r jasper/client/requirements.txt
#
#RUN apt install -y ash
RUN ARCH=`uname -m` && echo $ARCH
RUN /bin/bash -c 'set -xe && ARCH=`uname -m` && \
if [ "$ARCH" == "x86_64" ]; then \
echo "x86_64" && \
apt-get install -y software-properties-common && \
add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
apt update && \
apt install -y libjasper-dev ; \
fi'
RUN /bin/bash -c 'set -xe && ARCH=`uname -m` && \
if [[ "$ARCH" == arm* ]]; then \
echo "probably arm $ARCH" && \
git clone https://github.com/jasperproject/jasper-client.git jasper && \
chmod +x jasper/jasper.py && \
python3.7 -m pip install -r jasper/client/requirements.txt ; \
fi'
ARG NR_PROCS=1
ENV BUILD_FOLDER=/tmp_build/
RUN mkdir ${BUILD_FOLDER}
WORKDIR ${BUILD_FOLDER}
ADD https://github.com/opencv/opencv/archive/4.1.1.zip opencv.zip
ADD https://github.com/opencv/opencv_contrib/archive/4.1.1.zip opencv_contrib.zip
RUN set -ex && \
unzip -qq opencv.zip && \
unzip -qq opencv_contrib.zip && \
mv opencv-4.1.1 opencv && \
mv opencv_contrib-4.1.1 opencv_contrib
RUN set -ex && mkdir opencv/build && \
echo "unzipped! ";
WORKDIR ${BUILD_FOLDER}opencv/build
RUN python3.7 -m pip install numpy
RUN /bin/bash -c 'set -xe && ARCH=`uname -m` && \
if [ "$ARCH" == "x86_64" ]; then \
echo "x86_64" && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_opencv_python3=yes \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \
-D OPENCV_EXTRA_MODULES_PATH=${BUILD_FOLDER}opencv_contrib/modules \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D PYTHON3_EXECUTABLE=$(which python3.7) \
-D PYTHON_INCLUDE_DIR=$(python3.7 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_INCLUDE_DIR2=$(python3.7 -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \
-D PYTHON_LIBRARY=$(python3.7 -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3.7 -c "import numpy; print(numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$(python3.7 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
.. ; \
fi'
RUN /bin/bash -c 'set -xe && ARCH=`uname -m` && \
if [[ "$ARCH" == arm* ]]; then \
echo "probably arm $ARCH" && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_opencv_python3=yes \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_ENABLE_NONFREE=ON \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \
-D OPENCV_EXTRA_MODULES_PATH=${BUILD_FOLDER}opencv_contrib/modules \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D PYTHON3_EXECUTABLE=$(which python3.7) \
-D PYTHON_INCLUDE_DIR=$(python3.7 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_INCLUDE_DIR2=$(python3.7 -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \
-D PYTHON_LIBRARY=$(python3.7 -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3.7 -c "import numpy; print(numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$(python3.7 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
.. ; \
fi'
RUN set -xe && make -j${NR_PROCS} && make install && ldconfig
RUN python3.7 -c "import cv2; print(cv2.__version__)"
RUN apt clean
RUN rm -rf /var/lib/apt/lists/*

Remove as builder . It is used in multi-stage dockerfile.

There seems to be a bug, most probably related to moby/buildkit.
For more info an updates please check https://github.com/docker/buildx/issues/206

Related

Dockerfile not correctly installing dependencies

I am having an issue with installing dependencies with a Dockerfile. The image builds successfully, but when I attempt to test some of the dependencies installed in the Dockerfile below, they do not seem to be found. I am new to creating Dockerfiles so I am not sure if I am missing something. This may having something to do with environment variables? For example, I install sl as a test to confirm that something is not right. When a access a shell of my running image, running 'sl' returns "Command not found". Please let me know what I am doing wrong.
Here is my Dockerfile that I am using to build an image:
#FROM specifies the parent image from which we will construct our own custom image. This tomcat image contains a limited dist of Ubuntu, Tomcat9, and JRE11 ("temurin" is just a limited version of Java)
FROM tomcat:9-jre11-temurin
#add a maintainer label to the image
LABEL maintainer="Kerrick Cavanaugh - kerrickcavanaugh#ufl.edu"
#SciPy, Pandas, Numpy, other deps
RUN apt-get update && \
yes | apt-get -qq -y install \
git \
build-essential \
software-properties-common \
# python-dev \
python3 \
python3-dev \
python-dev \
libssl-dev \
# libffi-dev \
libxml2-dev \
libxslt1-dev \
apt-utils \
zlib1g-dev \
pip \
python3-pip \
sl \
gfortran \
libopenblas-dev \
liblapack-dev \
wget
# add /root/.local/bin to python path (causing warnings)
RUN python3 -c "import sys; sys.path.append('/root/.local/bin');"
RUN pip3 install --upgrade pip && pip3 install -vvv \
wheel \
matplotlib \
ipython \
jupyter \
sympy \
cython \
et-xmlfile==1.0.1 \
imbalanced-learn==0.5.0 \
imblearn==0.0 \
jdcal==1.4.1 \
joblib==0.14.0 \
numpy==1.16.4 \
scipy==1.3.1 \
openpyxl==2.6.4 \
pandas==0.24.2 \
python-dateutil==2.8.0 \
pytest==4.6.3 \
pytest-cov==2.7.1 \
pytz==2019.3 \
scikit-learn==0.21.3 \
six==1.12.0 \
xlrd==1.2.0
#R
RUN apt update && echo 'Y' | apt upgrade && \
#removed sudo from next 4
echo 'Y' | apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common && \
echo 'Y' | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
echo 'Y' | add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' && \
echo 'Y' | apt install r-base && \
R --version
#MATLAB???
#FSL
COPY ./aidp_docker/fslinstaller.py /usr/local/tomcat
#printf '36' | <-- for keyboard
#removed sudo
RUN apt-get update && apt-get -qq install python2
RUN { echo; echo '36'; } | python2 /usr/local/tomcat/fslinstaller.py -E -v -q > /dev/null
#AFNI
RUN cd && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_a_admin.txt && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_b_user.tcsh && \
curl -O https://raw.githubusercontent.com/afni/afni/master/src/other_builds/OS_notes.linux_ubuntu_20_64_c_nice.tcsh && \
#removed sudo
bash OS_notes.linux_ubuntu_20_64_a_admin.txt 2>&1 | tee o.ubuntu_20_a.txt && \
tcsh OS_notes.linux_ubuntu_20_64_b_user.tcsh 2>&1 | tee o.ubuntu_20_b.txt
#dcm2niix
RUN curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip
#ANTsR, ANTsRCore, ITKR
RUN git clone https://github.com/stnava/ITKR.git && \
git clone https://github.com/ANTsX/ANTsRCore.git && \
git clone https://github.com/ANTsX/ANTsR.git && \
R -e 'install.packages(c("Rcpp", "RcppEigen", "magrittr"))' && \
R CMD INSTALL ITKR && \
R CMD INSTALL ANTsRCore && \
R CMD INSTALL ANTsR
#COPY the specified folder structure and associated scripts to /usr/local/tomcat
COPY ./aidp_docker/ /usr/local/tomcat
#COPY wAIDP.war to the image
COPY ./wAIDP.war /usr/local/tomcat/webapps
#build complete
RUN echo 'Build complete!'
#runs the Docker image
CMD ["catalina.sh", "run"]

Docker failed to bind to $PORT within 60 seconds of launch – HEROKU ERROR

I am trying to deploy a Dockerfile from dockerhub on heroku using github workflow but I am getting error Failed to bind to $PORT within 60 seconds of launch – HEROKU ERROR.
Below is my Dockerfile.
FROM ghcr.io/linuxserver/baseimage-alpine:3.15
WORKDIR /app
# set version label
ARG UNRAR_VERSION=6.1.4
ARG BUILD_DATE
ARG VERSION
ARG SABNZBD_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thespad"
# environment settings
ENV HOME="/config" \
PORT=8080 \
PYTHONIOENCODING=utf-8
RUN \
echo "**** install packages ****" && \
apk add -U --update --no-cache --virtual=build-dependencies \
build-base \
g++ \
gcc \
libffi-dev \
make \
openssl-dev \
python3-dev && \
apk add -U --update --no-cache \
curl \
p7zip \
par2cmdline \
python3 \
py3-pip && \
echo "**** install unrar from source ****" && \
mkdir /tmp/unrar && \
curl -o \
/tmp/unrar.tar.gz -L \
"https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \
tar xf \
/tmp/unrar.tar.gz -C \
/tmp/unrar --strip-components=1 && \
cd /tmp/unrar && \
make && \
install -v -m755 unrar /usr/local/bin && \
echo "**** install sabnzbd ****" && \
if [ -z ${SABNZBD_VERSION+x} ]; then \
SABNZBD_VERSION=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
mkdir -p /app/sabnzbd && \
curl -o \
/tmp/sabnzbd.tar.gz -L \
"https://github.com/sabnzbd/sabnzbd/releases/download/${SABNZBD_VERSION}/SABnzbd-${SABNZBD_VERSION}-src.tar.gz" && \
tar xf \
/tmp/sabnzbd.tar.gz -C \
/app/sabnzbd --strip-components=1 && \
cd /app/sabnzbd && \
python3 -m pip install --upgrade pip && \
pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ \
wheel \
apprise \
pynzb \
requests && \
pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ -r requirements.txt && \
echo "**** install nzb-notify ****" && \
NZBNOTIFY_VERSION=$(curl -s https://api.github.com/repos/caronc/nzb-notify/releases/latest \
| awk '/tag_name/{print $4;exit}' FS='[""]') && \
mkdir -p /app/nzbnotify && \
curl -o \
/tmp/nzbnotify.tar.gz -L \
"https://api.github.com/repos/caronc/nzb-notify/tarball/${NZBNOTIFY_VERSION}" && \
tar xf \
/tmp/nzbnotify.tar.gz -C \
/app/nzbnotify --strip-components=1 && \
cd /app/nzbnotify && \
pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.15/ -r requirements.txt && \
echo "**** cleanup ****" && \
ln -s \
/usr/bin/python3 \
/usr/bin/python && \
apk del --purge \
build-dependencies && \
rm -rf \
/tmp/* \
$HOME/.cache
# add local files
COPY ./config /config
# ports and volumes
EXPOSE $PORT
# ENV LISTEN_PORT 8080
# PORT=8080
VOLUME /config
CMD exec /app/sabnzbd/Sabnzbd --NoRestart --NoUpdates -p $PORT
I don't know why heroku showing Port error even though I have exposed the port.
Can Anyone please help me with the error. I want to deploy Sabnzbd on heroku using Docker.

install opencv in existing dockerfile in gitlab

enter image description herei added below code to my docker file and the job run successfully but , in modules java in not available.
first FROM python:3.9
LABEL mantainer="Baher Elnaggar eng.baher77#gmail.com"
WORKDIR /opt/build
ENV OPENCV_VERSION="4.5.1"
RUN apt-get -qq update
&& apt-get -qq install -y --no-install-recommends
build-essential
cmake
git
wget
unzip
yasm
pkg-config
libswscale-dev
libtbb2
libtbb-dev
libjpeg-dev
libpng-dev
libtiff-dev
libopenjp2-7-dev
libavformat-dev
libpq-dev
&& pip install numpy
&& wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip \
&& unzip -qq opencv.zip -d /opt \
&& rm -rf opencv.zip \
&& cmake \
-D BUILD_TIFF=ON \
-D BUILD_opencv_java=OFF \
-D WITH_CUDA=OFF \
-D WITH_OPENGL=ON \
-D WITH_OPENCL=ON \
-D WITH_IPP=ON \
-D WITH_TBB=ON \
-D WITH_EIGEN=ON \
-D WITH_V4L=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$(python3.9 -c "import sys; print(sys.prefix)") \
-D PYTHON_EXECUTABLE=$(which python3.9) \
-D PYTHON_INCLUDE_DIR=$(python3.9 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_PACKAGES_PATH=$(python3.9 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
/opt/opencv-${OPENCV_VERSION} \
&& make -j$(nproc) \
&& make install \
&& rm -rf /opt/build/* \
&& rm -rf /opt/opencv-${OPENCV_VERSION} \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get -qq autoremove \
&& apt-get -qq clean
Then i added Java_home
RUN apt-get update &&
apt-get install -y openjdk-8-jdk &&
apt-get install -y ant &&
apt-get clean &&
rm -rf /var/lib/apt/lists/ &&
rm -rf /var/cache/oracle-jdk8-installer;
enter code here
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ RUN export JAVA_HOME
**But still job run successfully but my requirements is not satisfied . Can any one tell me to install opencv with java_home 8
My requirement is to add opencv layer to my docker image . i need to install OPENCV , i am added this code in my existing dockerfile in gitlab.**
but Old build getting deployed when you run the pipeline

How to define the setting in the docker image not run through jupyter notebook

I am trying to run the below docker image from https://hub.docker.com/r/fbcotter/docker-tensorflow-
opencv/
FROM tensorflow/tensorflow:1.8.0-py3
RUN apt-get update
RUN apt-get install -y \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libavformat-dev \
libhdf5-dev \
libpq-dev
RUN pip3 --no-cache-dir install \
numpy \
hdf5storage \
h5py \
scipy \
py3nvml
WORKDIR /
ENV OPENCV_VERSION="3.4.1"
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip \
&& unzip ${OPENCV_VERSION}.zip \
&& mkdir /opencv-${OPENCV_VERSION}/cmake_binary \
&& cd /opencv-${OPENCV_VERSION}/cmake_binary \
&& cmake -DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=OFF \
-DENABLE_AVX=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-DPYTHON_EXECUTABLE=$(which python3) \
-DPYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc;
print(get_python_inc())") \
-DPYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib;
print(get_python_lib())") .. \
&& make install \
&& rm /${OPENCV_VERSION}.zip \
&& rm -r /opencv-${OPENCV_VERSION}
RUN pip3 install -q keras==2.3.1
RUN pip3 install pyzmq
RUN pip3 install pillow
RUN mkdir -p /edge_app/src
WORKDIR /edge_app/src
COPY . ./
#CMD ["python","streamer.py"]
Command to run the docker image
docker run --rm -it -p:ip:port:port test
When I run the above docker image I am able to access it through Jupyter notebook. My question how to disable the jupyter notebook, because I want to access the docker container through bash.
Thanks, help is highly appreciated.
You could directly run your container with a custom command:
docker run -it -p port:port test /bin/bash

How do i clean up / minimize the storage usage of my container from building opencv in dockerfile

Given my docker file
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu14.04
RUN apt-get update
# disable interactive functions
ENV DEBIAN_FRONTEND noninteractive
#################Install MiniConda and other dependencies##########
ENV CONDA_DIR /opt/conda
ENV PATH $CONDA_DIR/bin:$PATH
ENV OPENBLAS_NUM_THREADS $(nproc)
RUN mkdir -p $CONDA_DIR && \
echo export PATH=$CONDA_DIR/bin:'$PATH' > /etc/profile.d/conda.sh && \
apt-get update -y && \
apt-get install -y \
wget \
git \
g++ \
graphviz \
software-properties-common \
python-software-properties \
python3-dev \
libhdf5-dev \
libopenblas-dev \
liblapack-dev \
libblas-dev \
libtbb2 \
libtbb-dev && \
apt-get -qq install -y \
build-essential \
unzip \
cmake \
pkg-config \
libjpeg8-dev \
libtiff4-dev \
libjasper-dev \
libpng12-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libatlas-base-dev \
gfortran && \
rm -rf /var/lib/apt/lists/* && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
/bin/bash /Miniconda3-latest-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-latest-Linux-x86_64.sh
#########################MPI###########################
RUN cd /tmp && \
wget "https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.gz" && \
tar xzf openmpi-2.1.1.tar.gz && \
cd openmpi-2.1.1 && \
./configure --with-cuda && make -j"$(nproc)" install # && ldconfig
#######################NCCL###########################
ENV CPATH /usr/local/cuda/include:/usr/local/include:$CPATH
RUN cd /usr/local && git clone https://github.com/NVIDIA/nccl.git && cd nccl && \
sed -i '/NVCC_GENCODE ?=/a \ -gencode=arch=compute_30,code=sm_30 \\' Makefile && \
make CUDA_HOME=/usr/local/cuda -j"$(nproc)" && \
make install && ldconfig
######### Compile for devices with cuda compute compatibility 3 (e.g. GRID K520 on aws) second line above
# UNCOMMENT line below to compile for GPUs with cuda compute compatibility 3.0
# sed -i '/NVCC_GENCODE ?=/a \ -gencode=arch=compute_30,code=sm_30 \\' Makefile && \
##########
###################Setup User##########################
ENV NB_USER chainer
ENV NB_UID 1000
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER -g sudo -p $(perl -e'print crypt("chainer", "aa")') && \
mkdir -p $CONDA_DIR && \
chown chainer $CONDA_DIR -R && \
mkdir -p /src && \
chown -R chainer /src
# mkdir -p /opencv && \
# chown -R chainer /opencv && \
# mkdir -p /opencv_contrib && \
# chown -R chainer /opencv_contrib
####################Python 3#########################
ARG python_version=3.5.2
RUN conda install -y python=${python_version} && \
pip install -U pip && \
conda install Pillow scikit-learn notebook pandas matplotlib mkl nose pyyaml six h5py && \
pip install numpy && \
pip install chainer && \
pip install chainercv && \
# pip install opencv-python && \
pip install pyyaml && \
conda clean -yt
# pip install -U pip && \
#
# conda install Pillow scikit-learn notebook pandas matplotlib mkl nose pyyaml six h5py && \
#
#
# pip install mpi4py && \
# pip install cython && \
#
# pip install chainer && \
# pip install chainercv && \
# pip install chainermn && \
ENV PYTHONPATH $CONDA_DIR/lib/python3.5/site-packages/:$PYTHONPATH
ENV PYTHONPATH /src/:$PYTHONPATH
WORKDIR /src
##OPENCV##
RUN wget https://github.com/Itseez/opencv/archive/3.3.0.zip -O opencv3.zip && \
unzip -q opencv3.zip && mv /src/opencv-3.3.0 /opencv && \
wget https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip -O opencv_contrib3.zip && \
unzip -q opencv_contrib3.zip && mv /src/opencv_contrib-3.3.0 /opencv_contrib
RUN rm -r -f /opencv/build && mkdir /opencv/build && \
cd /opencv/build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_PYTHON_SUPPORT=ON \
-D CMAKE_INSTALL_PREFIX=$CONDA_DIR \
-D PYTHON3_LIBRARY=$CONDA_DIR/lib/python3.5 \
-D PYTHON3_INCLUDE_DIRS=$CONDA_DIR/include/python3.5m \
-D PYTHON3_EXECUTABLE=$CONDA_DIR/bin/python3 \
-D PYTHON3_PACKAGES_PATH=$CONDA_DIR/lib/python3.5/site-packages \
-D WITH_TBB=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_IPP=OFF \
-D WITH_V4L=ON .. && \
make -j"$(nproc)" && \
make install && \
ldconfig
######################################################
USER chainer
It ends up at whooping 15GB in size.
What can I do to reduce the size in terms of all the selfbuild stuff happening? can some be deleted again?

Resources