FROM pdal/alpinebase:latest as builder

RUN    \
    git clone https://github.com/PDAL/PDAL.git --branch 2.0-maintenance --single-branch pdal; \
    cd pdal; \
    mkdir build; \
    cd build; \
    cmake .. \
        -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_PLUGIN_NITF=ON \
        -DBUILD_PLUGIN_CPD=ON \
        -DBUILD_PLUGIN_ICEBRIDGE=ON \
        -DBUILD_PLUGIN_PGPOINTCLOUD=ON \
        -DBUILD_PLUGIN_SQLITE=ON \
        -DBUILD_PLUGIN_I3S=ON \
        -DBUILD_PLUGIN_E57=ON \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_INSTALL_LIBDIR=lib \
        ; \
    ninja install; \
    cd /; \
    rm -rf pdal; \
    \
    apk del \
        git \
        cmake \
        ninja \
        g++ \
    ; \
    rm -rf /usr/share/hdf5_examples; \
    rm /usr/lib/*.a; \
    rm /usr/bin/gdal*; \
    rm /usr/bin/ogr*; \
    rm /usr/bin/h5*;

FROM alpine:3.11
RUN apk add --no-cache ca-certificates

COPY --from=builder /usr/ /usr/
COPY --from=builder /lib/ /lib/

