Skip to content

Commit

Permalink
refactor Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Dec 31, 2024
1 parent eeaf048 commit 225a7a5
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 48 deletions.
15 changes: 9 additions & 6 deletions Dockerfile-cluster
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
ARG BASE_IMAGE=unset
ARG INSTALL_DIR=/opt/LightGBM

# hadolint ignore=DL3006
FROM ${BASE_IMAGE}

COPY LightGBM/ ${INSTALL_DIR}/
RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM \
<<EOF
cd /tmp/LightGBM

RUN cd "${INSTALL_DIR}" && \
sh ./build-python.sh install --precompile && \
cd /opt && \
rm -rf "${INSTALL_DIR}"
# build lightgbm package, install to site-packages/
sh ./build-python.sh install --precompile

# clear pip's cache
rm -rf ~/.cache
EOF
46 changes: 29 additions & 17 deletions Dockerfile-cluster-base
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,31 @@ find \
/usr/local/lib/python${PYTHON_VERSION}/site-packages \
-type f \
\( \
-name '*.c' \
-o -name '*.cc' \
-o -name '*.cpp' \
-o -name '*.h' \
-o -name '*.hpp' \
-o -wholename '*bokeh/sampledata/*' \
-o -wholename '*dask/*tests/*' \
-o -wholename '*joblib/test/*' \
-o -wholename '*llvmlite/tests/*' \
-o -wholename '*numba/*tests/*' \
-o -wholename '*numpy/*tests/*' \
-o -wholename '*pandas/*tests/*' \
-o -wholename '*scikit-learn/tests*' \
-o -wholename '*scikit-learn/*/tests*' \
-o -wholename '*scipy/*/tests*' \
-o -wholename '*tornado/test/*' \
-o -wholename '*/__pycache__/*' \
-name '*.c' \
-o -name '*.cc' \
-o -name '*.cpp' \
-o -name '*.h' \
-o -name '*.hpp' \
-o -wholename '*bokeh/sampledata/*' \
-o -wholename '*dask/*tests/*' \
-o -wholename '*joblib/test/*' \
-o -wholename '*llvmlite/tests/*' \
-o -wholename '*numba/*tests/*' \
-o -wholename '*numpy/*tests/*' \
-o -wholename '*pandas/tests*' \
-o -wholename '*pandas/*/tests/*' \
-o -wholename '*psutil/tests/*' \
-o -wholename 'pyarrow/_pyarrow_cpp_tests*' \
-o -wholename '*scikit-learn/tests*' \
-o -wholename '*scikit-learn/*/tests*' \
-o -wholename '*sklearn/tests*' \
-o -wholename '*sklearn/*/tests*' \
-o -wholename '*scipy/*/tests*' \
-o -wholename '*sparse/*/tests/*' \
-o -wholename '*toolz/tests/*' \
-o -wholename '*tornado/test/*' \
-o -wholename '*zict/tests/*' \
-o -wholename '*/__pycache__/*' \
\) \
-exec rm '{}' '+'

Expand All @@ -67,5 +75,9 @@ find \

# clean apt-get files
apt-get clean
apt-get purge -y --auto-remove
rm -rf /var/lib/apt/lists/*

# clean other files
rm -rf ~/.cache
EOF
16 changes: 10 additions & 6 deletions Dockerfile-notebook
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
ARG BASE_IMAGE=unset
ARG INSTALL_DIR=/root/testing/LightGBM

# hadolint ignore=DL3006
FROM ${BASE_IMAGE}

COPY jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
COPY LightGBM/ ${INSTALL_DIR}/

RUN cd "${INSTALL_DIR}" && \
sh ./build-python.sh install --precompile && \
cd /root/ && \
rm -rf "${INSTALL_DIR}"
RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM \
<<EOF
cd /tmp/LightGBM

# build lightgbm package, install to site-packages/
sh ./build-python.sh install --precompile

# clear pip's cache
rm -rf ~/.cache
EOF

WORKDIR /root/testing/notebooks
46 changes: 29 additions & 17 deletions Dockerfile-notebook-base
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,31 @@ find \
/usr/local/lib/python${PYTHON_VERSION}/site-packages \
-type f \
\( \
-name '*.c' \
-o -name '*.cc' \
-o -name '*.cpp' \
-o -name '*.h' \
-o -name '*.hpp' \
-o -wholename '*bokeh/sampledata/*' \
-o -wholename '*dask/*tests/*' \
-o -wholename '*joblib/test/*' \
-o -wholename '*llvmlite/tests/*' \
-o -wholename '*numba/*tests/*' \
-o -wholename '*numpy/*tests/*' \
-o -wholename '*pandas/*tests/*' \
-o -wholename '*scikit-learn/tests*' \
-o -wholename '*scikit-learn/*/tests*' \
-o -wholename '*scipy/*/tests*' \
-o -wholename '*tornado/test/*' \
-o -wholename '*/__pycache__/*' \
-name '*.c' \
-o -name '*.cc' \
-o -name '*.cpp' \
-o -name '*.h' \
-o -name '*.hpp' \
-o -wholename '*bokeh/sampledata/*' \
-o -wholename '*dask/*tests/*' \
-o -wholename '*joblib/test/*' \
-o -wholename '*llvmlite/tests/*' \
-o -wholename '*numba/*tests/*' \
-o -wholename '*numpy/*tests/*' \
-o -wholename '*pandas/tests*' \
-o -wholename '*pandas/*/tests/*' \
-o -wholename '*psutil/tests/*' \
-o -wholename 'pyarrow/_pyarrow_cpp_tests*' \
-o -wholename '*scikit-learn/tests*' \
-o -wholename '*scikit-learn/*/tests*' \
-o -wholename '*sklearn/tests*' \
-o -wholename '*sklearn/*/tests*' \
-o -wholename '*scipy/*/tests*' \
-o -wholename '*sparse/*/tests/*' \
-o -wholename '*toolz/tests/*' \
-o -wholename '*tornado/test/*' \
-o -wholename '*zict/tests/*' \
-o -wholename '*/__pycache__/*' \
\) \
-exec rm '{}' '+'

Expand All @@ -71,7 +79,11 @@ find \

# clean apt-get files
apt-get clean
apt-get purge -y --auto-remove
rm -rf /var/lib/apt/lists/*

# clean other files
rm -rf ~/.cache
EOF

ENTRYPOINT ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--port=8888"]
9 changes: 7 additions & 2 deletions bin/install-cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ set -e -u -o pipefail

CMAKE_VERSION=${1}

declare -r install_script
install_script="cmake-${CMAKE_VERSION}-linux-$(arch).sh"

curl -O -L \
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(arch).sh"
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${install_script}"

mkdir /opt/cmake
sh "cmake-${CMAKE_VERSION}-linux-$(arch).sh" \
sh "${install_script}" \
--skip-license \
--prefix=/opt/cmake

rm "./${install_script}"

ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake

0 comments on commit 225a7a5

Please sign in to comment.