Skip to content

Commit 225a7a5

Browse files
committed
refactor Dockerfiles
1 parent eeaf048 commit 225a7a5

File tree

5 files changed

+84
-48
lines changed

5 files changed

+84
-48
lines changed

Dockerfile-cluster

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
ARG BASE_IMAGE=unset
2-
ARG INSTALL_DIR=/opt/LightGBM
32

43
# hadolint ignore=DL3006
54
FROM ${BASE_IMAGE}
65

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

9-
RUN cd "${INSTALL_DIR}" && \
10-
sh ./build-python.sh install --precompile && \
11-
cd /opt && \
12-
rm -rf "${INSTALL_DIR}"
10+
# build lightgbm package, install to site-packages/
11+
sh ./build-python.sh install --precompile
12+
13+
# clear pip's cache
14+
rm -rf ~/.cache
15+
EOF

Dockerfile-cluster-base

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,31 @@ find \
3939
/usr/local/lib/python${PYTHON_VERSION}/site-packages \
4040
-type f \
4141
\( \
42-
-name '*.c' \
43-
-o -name '*.cc' \
44-
-o -name '*.cpp' \
45-
-o -name '*.h' \
46-
-o -name '*.hpp' \
47-
-o -wholename '*bokeh/sampledata/*' \
48-
-o -wholename '*dask/*tests/*' \
49-
-o -wholename '*joblib/test/*' \
50-
-o -wholename '*llvmlite/tests/*' \
51-
-o -wholename '*numba/*tests/*' \
52-
-o -wholename '*numpy/*tests/*' \
53-
-o -wholename '*pandas/*tests/*' \
54-
-o -wholename '*scikit-learn/tests*' \
55-
-o -wholename '*scikit-learn/*/tests*' \
56-
-o -wholename '*scipy/*/tests*' \
57-
-o -wholename '*tornado/test/*' \
58-
-o -wholename '*/__pycache__/*' \
42+
-name '*.c' \
43+
-o -name '*.cc' \
44+
-o -name '*.cpp' \
45+
-o -name '*.h' \
46+
-o -name '*.hpp' \
47+
-o -wholename '*bokeh/sampledata/*' \
48+
-o -wholename '*dask/*tests/*' \
49+
-o -wholename '*joblib/test/*' \
50+
-o -wholename '*llvmlite/tests/*' \
51+
-o -wholename '*numba/*tests/*' \
52+
-o -wholename '*numpy/*tests/*' \
53+
-o -wholename '*pandas/tests*' \
54+
-o -wholename '*pandas/*/tests/*' \
55+
-o -wholename '*psutil/tests/*' \
56+
-o -wholename 'pyarrow/_pyarrow_cpp_tests*' \
57+
-o -wholename '*scikit-learn/tests*' \
58+
-o -wholename '*scikit-learn/*/tests*' \
59+
-o -wholename '*sklearn/tests*' \
60+
-o -wholename '*sklearn/*/tests*' \
61+
-o -wholename '*scipy/*/tests*' \
62+
-o -wholename '*sparse/*/tests/*' \
63+
-o -wholename '*toolz/tests/*' \
64+
-o -wholename '*tornado/test/*' \
65+
-o -wholename '*zict/tests/*' \
66+
-o -wholename '*/__pycache__/*' \
5967
\) \
6068
-exec rm '{}' '+'
6169

@@ -67,5 +75,9 @@ find \
6775

6876
# clean apt-get files
6977
apt-get clean
78+
apt-get purge -y --auto-remove
7079
rm -rf /var/lib/apt/lists/*
80+
81+
# clean other files
82+
rm -rf ~/.cache
7183
EOF

Dockerfile-notebook

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
ARG BASE_IMAGE=unset
2-
ARG INSTALL_DIR=/root/testing/LightGBM
32

43
# hadolint ignore=DL3006
54
FROM ${BASE_IMAGE}
65

76
COPY jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
8-
COPY LightGBM/ ${INSTALL_DIR}/
97

10-
RUN cd "${INSTALL_DIR}" && \
11-
sh ./build-python.sh install --precompile && \
12-
cd /root/ && \
13-
rm -rf "${INSTALL_DIR}"
8+
RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM \
9+
<<EOF
10+
cd /tmp/LightGBM
11+
12+
# build lightgbm package, install to site-packages/
13+
sh ./build-python.sh install --precompile
14+
15+
# clear pip's cache
16+
rm -rf ~/.cache
17+
EOF
1418

1519
WORKDIR /root/testing/notebooks

Dockerfile-notebook-base

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,31 @@ find \
4343
/usr/local/lib/python${PYTHON_VERSION}/site-packages \
4444
-type f \
4545
\( \
46-
-name '*.c' \
47-
-o -name '*.cc' \
48-
-o -name '*.cpp' \
49-
-o -name '*.h' \
50-
-o -name '*.hpp' \
51-
-o -wholename '*bokeh/sampledata/*' \
52-
-o -wholename '*dask/*tests/*' \
53-
-o -wholename '*joblib/test/*' \
54-
-o -wholename '*llvmlite/tests/*' \
55-
-o -wholename '*numba/*tests/*' \
56-
-o -wholename '*numpy/*tests/*' \
57-
-o -wholename '*pandas/*tests/*' \
58-
-o -wholename '*scikit-learn/tests*' \
59-
-o -wholename '*scikit-learn/*/tests*' \
60-
-o -wholename '*scipy/*/tests*' \
61-
-o -wholename '*tornado/test/*' \
62-
-o -wholename '*/__pycache__/*' \
46+
-name '*.c' \
47+
-o -name '*.cc' \
48+
-o -name '*.cpp' \
49+
-o -name '*.h' \
50+
-o -name '*.hpp' \
51+
-o -wholename '*bokeh/sampledata/*' \
52+
-o -wholename '*dask/*tests/*' \
53+
-o -wholename '*joblib/test/*' \
54+
-o -wholename '*llvmlite/tests/*' \
55+
-o -wholename '*numba/*tests/*' \
56+
-o -wholename '*numpy/*tests/*' \
57+
-o -wholename '*pandas/tests*' \
58+
-o -wholename '*pandas/*/tests/*' \
59+
-o -wholename '*psutil/tests/*' \
60+
-o -wholename 'pyarrow/_pyarrow_cpp_tests*' \
61+
-o -wholename '*scikit-learn/tests*' \
62+
-o -wholename '*scikit-learn/*/tests*' \
63+
-o -wholename '*sklearn/tests*' \
64+
-o -wholename '*sklearn/*/tests*' \
65+
-o -wholename '*scipy/*/tests*' \
66+
-o -wholename '*sparse/*/tests/*' \
67+
-o -wholename '*toolz/tests/*' \
68+
-o -wholename '*tornado/test/*' \
69+
-o -wholename '*zict/tests/*' \
70+
-o -wholename '*/__pycache__/*' \
6371
\) \
6472
-exec rm '{}' '+'
6573

@@ -71,7 +79,11 @@ find \
7179

7280
# clean apt-get files
7381
apt-get clean
82+
apt-get purge -y --auto-remove
7483
rm -rf /var/lib/apt/lists/*
84+
85+
# clean other files
86+
rm -rf ~/.cache
7587
EOF
7688

7789
ENTRYPOINT ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--port=8888"]

bin/install-cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ set -e -u -o pipefail
44

55
CMAKE_VERSION=${1}
66

7+
declare -r install_script
8+
install_script="cmake-${CMAKE_VERSION}-linux-$(arch).sh"
9+
710
curl -O -L \
8-
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(arch).sh"
11+
"https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${install_script}"
912

1013
mkdir /opt/cmake
11-
sh "cmake-${CMAKE_VERSION}-linux-$(arch).sh" \
14+
sh "${install_script}" \
1215
--skip-license \
1316
--prefix=/opt/cmake
1417

18+
rm "./${install_script}"
19+
1520
ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake

0 commit comments

Comments
 (0)