-
Notifications
You must be signed in to change notification settings - Fork 0
/
blueprint_pdal.Dockerfile
252 lines (213 loc) · 7.77 KB
/
blueprint_pdal.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# CentOS 7 with PDAL
# - includes manually built dependencies LASZIP, LAZPERF, Nitro
# - compatible with pypi PDAL bindings (recipe does not build python bindings)
# - use must include the GDAL recipe in their dockerfile
#
# This dockerfile follows procedures from the offical PDAL dockers
# https://github.com/PDAL/PDAL/blob/2.3.0/scripts/docker/centos/Dockerfile
#
# This dockerfile is derived from the manylinux2014 base image, derived from
# CentOS 7 and already containing many updated build essentials.
# https://github.com/pypa/manylinux
#
# As this base image includes build essentials already in /usr/local,
# libraries are staged in "/staging/usr/local". The last build step clears
# /usr/local of other packages, then migrates the staging directory to
# /usr/local for consistency with other recipes.
# -----------------------------------------------------------------------------
# BASE IMAGE
# -----------------------------------------------------------------------------
# global args
ARG BASE_IMAGE="quay.io/pypa/manylinux2014_x86_64:2024-07-02-9ac04ee"
ARG GDAL_IMAGE="vsiri/blueprint:gdal"
# blueprint dependencies
FROM ${GDAL_IMAGE} AS gdal
# base image
FROM ${BASE_IMAGE} AS base
# Set shell to bash
SHELL ["/usr/bin/env", "/bin/bash", "-euxvc"]
# staging & reporting directories, reused by each stage
ENV STAGING_DIR="/staging"
ENV REPORT_DIR="${STAGING_DIR}/usr/local/share/just/info"
RUN mkdir -p "${STAGING_DIR}" "${REPORT_DIR}";
# working directory (for download, unpack, build, etc.)
WORKDIR /tmp
# -----------------------------------------------------------------------------
# LASZIP
# -----------------------------------------------------------------------------
FROM base AS laszip
# version argument
ARG LASZIP_VERSION=3.4.3
# install
RUN \
# download & unzip
TAR_FILE="laszip-src-${LASZIP_VERSION}.tar.gz"; \
curl -fsSLO "https://github.com/LASzip/LASzip/releases/download/${LASZIP_VERSION}/${TAR_FILE}"; \
tar -xvf "${TAR_FILE}" --strip-components=1; \
#
# configure, build, & install
cmake . \
-D CMAKE_BUILD_TYPE=Release; \
make -j"$(nproc)"; \
make install DESTDIR="${STAGING_DIR}"; \
echo "${LASZIP_VERSION}" > "${REPORT_DIR}/laszip_version"; \
#
# cleanup
rm -rf /tmp/*;
# -----------------------------------------------------------------------------
# LAZ-PERF
# -----------------------------------------------------------------------------
FROM base AS lazperf
# version argument
ARG LAZPERF_VERSION=2.1.0
# install
RUN \
# download & unzip
TAR_FILE="${LAZPERF_VERSION}.tar.gz"; \
curl -fsSLO "https://github.com/hobu/laz-perf/archive/refs/tags/${TAR_FILE}"; \
tar -xvf "${TAR_FILE}" --strip-components=1; \
#
# configure, build, & install
cmake . \
-D CMAKE_BUILD_TYPE=Release \
-D WITH_TESTS=OFF; \
make -j"$(nproc)"; \
make install DESTDIR="${STAGING_DIR}"; \
echo "${LAZPERF_VERSION}" > "${REPORT_DIR}/lazperf_version"; \
#
# cleanup
rm -rf /tmp/*;
# -----------------------------------------------------------------------------
# NITRO NITF
# -----------------------------------------------------------------------------
FROM base AS nitro
# version argument
ARG NITRO_VERSION=2.7dev-6
# install
RUN \
# download & unzip
TAR_FILE="${NITRO_VERSION}.tar.gz"; \
curl -fsSLO "https://github.com/hobu/nitro/archive/refs/tags/${TAR_FILE}"; \
tar -xvf "${TAR_FILE}" --strip-components=1; \
#
# configure, build, & install
cmake . \
-D CMAKE_BUILD_TYPE=Release; \
make -j"$(nproc)"; \
make install DESTDIR="${STAGING_DIR}"; \
echo "${NITRO_VERSION}" > "${REPORT_DIR}/nitro_version"; \
#
# cleanup
rm -rf /tmp/*;
# -----------------------------------------------------------------------------
# PDAL setup for build
# -----------------------------------------------------------------------------
FROM base AS setup
# version argument
ARG PDAL_VERSION=2.3.0
ENV PDAL_VERSION=${PDAL_VERSION}
# additional build dependencies
RUN ulimit -n 1024; \
yum install -y \
libcurl-devel \
libjpeg-turbo-devel \
libxml2-devel \
zlib-devel; \
yum clean all
# -----------------------------------------------------------------------------
# PDAL build library
# -----------------------------------------------------------------------------
FROM setup AS library
# local dependencies to staging directory
# the base has many other dependencies already in /usr/local,
# so we isolate packages in a staging directory
COPY --from=laszip ${STAGING_DIR} ${STAGING_DIR}
COPY --from=lazperf ${STAGING_DIR} ${STAGING_DIR}
COPY --from=nitro ${STAGING_DIR} ${STAGING_DIR}
# copy GDAL to /usr/local - GDAL will be copied into downstream dockers
# independently, and should not be added to staging
COPY --from=gdal /usr/local /usr/local
# install
RUN \
# download & unzip
TAR_FILE="PDAL-${PDAL_VERSION}-src.tar.gz"; \
curl -fsSLO "https://github.com/PDAL/PDAL/releases/download/${PDAL_VERSION}/${TAR_FILE}"; \
tar -xf "${TAR_FILE}" --strip-components=1; \
#
# configure, build, & install
cmake . \
-D CMAKE_PREFIX_PATH="${STAGING_DIR}/usr/local" \
-D CMAKE_BUILD_TYPE=Release \
-D WITH_LASZIP=ON \
-D WITH_LAZPERF=ON \
-D BUILD_PLUGIN_NITF=ON \
-D WITH_ZLIB=ON \
-D WITH_TESTS=OFF \
| tee "${REPORT_DIR}/pdal_configure"; \
make -j "$(nproc)"; \
make install "DESTDIR=${STAGING_DIR}"; \
echo "${PDAL_VERSION}" > "${REPORT_DIR}/pdal_version"; \
#
# cleanup
rm -rf /tmp/*;
# -----------------------------------------------------------------------------
# PDAL build wheel
# -----------------------------------------------------------------------------
FROM setup AS wheel
# version arguments
# note pdal-python is hosted/versioned separately from PDAL
ARG PDAL_PYTHON_VERSION=3.0.2
ARG PYTHON_VERSION=3.9
ARG NUMPY_VERSION=1.22.3
# wheel directory
ENV WHEEL_DIR="${STAGING_DIR}/usr/local/share/just/wheels"
# local dependencies to /usr/local
COPY --from=gdal /usr/local /usr/local
COPY --from=library ${STAGING_DIR}/usr/local /usr/local
# build wheels
RUN mkdir -p "${WHEEL_DIR}"; \
#
# download pdal-python
TAR_FILE="${PDAL_PYTHON_VERSION}.tar.gz"; \
curl -fsSLO "https://github.com/PDAL/python/archive/refs/tags/${TAR_FILE}"; \
tar -xf "${TAR_FILE}" --strip-components=1; \
#
# workaround - wheel succeeds for Development.Module
# https://gitlab.kitware.com/cmake/cmake/-/issues/20425
# https://github.com/google/or-tools/issues/2774
sed -i '/^[ ]*find_package/s/Development /Development.Module /g' ./CMakeLists.txt; \
#
# python flavor
PYBIN=$(ver=$(echo ${PYTHON_VERSION} | sed -E 's|(.)\.([^.]*).*|\1\2|'); \
echo /opt/python/cp${ver}-*/bin); \
#
# install python dependencies
"${PYBIN}/pip" install \
ninja \
numpy==${NUMPY_VERSION} \
pybind11[global] \
scikit-build; \
#
# build wheel
# Note $PYBIN is added to the path to allow cmake (used during the build
# process) to identify the correct python version
PATH="${PYBIN}:$PATH"; \
"${PYBIN}/pip" wheel . \
--no-deps --no-build-isolation -w "${WHEEL_DIR}"; \
#
# cleanup
rm -rf /tmp/*; \
ls -la "${WHEEL_DIR}";
# -----------------------------------------------------------------------------
# PDAL final
# -----------------------------------------------------------------------------
FROM base
# clear /usr/local
RUN rm -rf /usr/local/*
# migrate staging directory to /usr/local
COPY --from=library ${STAGING_DIR}/usr/local /usr/local
COPY --from=wheel ${STAGING_DIR}/usr/local /usr/local
# Patch file for downstream image
ENV PDAL_PATCH_FILE=/usr/local/share/just/container_build_patch/30_pdal
ADD 30_pdal ${PDAL_PATCH_FILE}
RUN chmod +x ${PDAL_PATCH_FILE}