-
-
Save vincentsarago/084ce7c49e9d8e6c2ed6d3a2eb8cb9e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM public.ecr.aws/lambda/provided:al2 as builder | |
LABEL maintainer="lambgeo <geolambdas@gmail.com>" | |
RUN yum makecache fast | |
RUN yum install -y git autoconf libtool flex bison cmake make tar gzip gcc gcc-c++ automake16 libpng-devel nasm libxml2-devel readline-devel openssl-devel curl-devel cmake3 | |
RUN | |
ENV PREFIX /opt | |
WORKDIR /opt | |
ENV LD_LIBRARY_PATH $PREFIX/lib:$LD_LIBRARY_PATH | |
# pkg-config | |
ENV PKGCONFIG_VERSION=0.29.2 | |
RUN mkdir /tmp/pkg-config \ | |
&& curl -sfL https://pkg-config.freedesktop.org/releases/pkg-config-${PKGCONFIG_VERSION}.tar.gz | tar zxf - -C /tmp/pkg-config --strip-components=1 \ | |
&& cd /tmp/pkg-config \ | |
&& CFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --with-internal-glib \ | |
&& make -j $(nproc) --silent && make install && make clean \ | |
&& rm -rf /tmp/pkg-config | |
ENV PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/ | |
# sqlite | |
RUN mkdir /tmp/sqlite \ | |
&& curl -sfL https://www.sqlite.org/2020/sqlite-autoconf-3330000.tar.gz | tar zxf - -C /tmp/sqlite --strip-components=1 \ | |
&& cd /tmp/sqlite \ | |
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --disable-static \ | |
&& make -j $(nproc) --silent && make install && make clean \ | |
&& rm -rf /tmp/sqlite | |
# libexpat | |
RUN mkdir /tmp/libexpat \ | |
&& curl -sfL https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.gz | tar zxf - -C /tmp/libexpat --strip-components=1 \ | |
&& cd /tmp/libexpat \ | |
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --disable-static \ | |
&& make -j $(nproc) --silent && make install && make clean \ | |
&& rm -rf /tmp/libexpat | |
ENV \ | |
SQLITE3_LIBS="-L${PREFIX}/lib -lsqlite3" \ | |
SQLITE3_INCLUDE_DIR="${PREFIX}/include" \ | |
SQLITE3_CFLAGS="$CFLAGS -I${PREFIX}/include" \ | |
PATH=${PREFIX}/bin/:$PATH | |
# nghttp2 | |
ENV NGHTTP2_VERSION=1.42.0 | |
RUN mkdir /tmp/nghttp2 \ | |
&& curl -sfL https://github.com/nghttp2/nghttp2/releases/download/v${NGHTTP2_VERSION}/nghttp2-${NGHTTP2_VERSION}.tar.gz | tar zxf - -C /tmp/nghttp2 --strip-components=1 \ | |
&& cd /tmp/nghttp2 \ | |
&& ./configure --enable-lib-only --prefix=$PREFIX \ | |
&& make -j $(nproc) --silent && make install && make clean \ | |
&& rm -rf /tmp/nghttp2 | |
# libcurl | |
ENV CURL_VERSION=7.73.0 | |
RUN mkdir /tmp/libcurl \ | |
&& curl -sfL https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz | tar zxf - -C /tmp/libcurl --strip-components=1 \ | |
&& cd /tmp/libcurl \ | |
&& ./configure --disable-manual --disable-cookies --with-nghttp2=$PREFIX --prefix=$PREFIX \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/libcurl | |
# libdeflate | |
RUN mkdir /tmp/libdeflate \ | |
&& curl -sfL https://github.com/ebiggers/libdeflate/archive/v1.10.tar.gz | tar zxf - -C /tmp/libdeflate --strip-components=1 \ | |
&& cd /tmp/libdeflate \ | |
&& make -j $(nproc) --silent PREFIX=$PREFIX && make install \ | |
&& rm -rf /tmp/libdeflate | |
# libpng | |
ENV LIBPNG_VERSION=1.6.37 | |
RUN mkdir /tmp/png \ | |
&& curl -sfL https://github.com/glennrp/libpng/archive/v${LIBPNG_VERSION}.tar.gz | tar zxf - -C /tmp/png --strip-components=1 \ | |
&& cd /tmp/png \ | |
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/png | |
# libjpeg_turbo | |
ENV LIBJPEG_TURBO_VERSION=2.1.3 | |
RUN mkdir /tmp/jpeg \ | |
&& curl -sfL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${LIBJPEG_TURBO_VERSION}.tar.gz | tar zxf - -C /tmp/jpeg --strip-components=1 \ | |
&& cd /tmp/jpeg \ | |
&& mkdir build && cd build \ | |
&& cmake3 .. \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
-DCMAKE_INSTALL_LIBDIR:PATH=lib \ | |
-DCMAKE_C_FLAGS="-O2 -Wl,-S" \ | |
-DCMAKE_CXX_FLAGS="-O2 -Wl,-S" \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/jpeg | |
# webp | |
ENV WEBP_VERSION=1.1.0 | |
RUN mkdir /tmp/webp \ | |
&& curl -sfL https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz | tar zxf - -C /tmp/webp --strip-components=1 \ | |
&& cd /tmp/webp \ | |
&& CFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/webp | |
# zstd | |
ENV ZSTD_VERSION=1.4.5 | |
RUN mkdir /tmp/zstd \ | |
&& curl -sfL https://github.com/facebook/zstd/archive/v${ZSTD_VERSION}.tar.gz | tar zxf - -C /tmp/zstd --strip-components=1 \ | |
&& cd /tmp/zstd \ | |
&& make -j $(nproc) PREFIX=$PREFIX ZSTD_LEGACY_SUPPORT=0 CFLAGS=-O1 --silent && make install PREFIX=$PREFIX ZSTD_LEGACY_SUPPORT=0 CFLAGS=-O1 \ | |
&& rm -rf /tmp/zstd | |
# lerc | |
ENV LERC_VERSION=2.2.1 | |
RUN mkdir /tmp/lerc \ | |
&& curl -sfL https://github.com/Esri/lerc/archive/v${LERC_VERSION}.tar.gz | tar zxf - -C /tmp/lerc --strip-components=1 \ | |
&& cd /tmp/lerc \ | |
&& cmake3 . \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
-DCMAKE_INSTALL_LIBDIR:PATH=lib \ | |
-DCMAKE_C_FLAGS="-O2 -Wl,-S" \ | |
-DCMAKE_CXX_FLAGS="-O2 -Wl,-S" \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/lerc | |
# libtiff | |
ENV LIBTIFF_VERSION=4.3.0 | |
RUN mkdir /tmp/libtiff \ | |
&& curl -sfL https://download.osgeo.org/libtiff/tiff-${LIBTIFF_VERSION}.tar.gz | tar zxf - -C /tmp/libtiff --strip-components=1 \ | |
&& cd /tmp/libtiff \ | |
&& LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'" CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure \ | |
--prefix=$PREFIX \ | |
--disable-static \ | |
--enable-rpath \ | |
--with-lerc-lib-dir=$PREFIX/lib \ | |
--with-lerc-include-dir=$PREFIX/include \ | |
--with-libdeflate-lib-dir=$PREFIX/lib \ | |
--with-libdeflate-include-dir=$PREFIX/include \ | |
--with-jpeg-lib-dir=$PREFIX/lib \ | |
--with-jpeg-include-dir=$PREFIX/include \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/libtiff | |
# postgres | |
ENV PG_VERSION=13.0 | |
RUN mkdir /tmp/postgres \ | |
&& curl -sfL https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.gz | tar zxf - -C /tmp/postgres --strip-components=1 \ | |
&& cd /tmp/postgres \ | |
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --with-openssl \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/postgres | |
# openjpeg | |
ENV OPENJPEG_VERSION=2.4.0 | |
RUN mkdir /tmp/openjpeg \ | |
&& curl -sfL https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz | tar zxf - -C /tmp/openjpeg --strip-components=1 \ | |
&& cd /tmp/openjpeg \ | |
&& mkdir build && cd build \ | |
&& cmake3 .. \ | |
-DBUILD_THIRDPARTY:BOOL=ON \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
-DCMAKE_INSTALL_LIBDIR:PATH=lib \ | |
-DCMAKE_C_FLAGS="-O2 -Wl,-S" \ | |
-DCMAKE_CXX_FLAGS="-O2 -Wl,-S" \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/openjpeg | |
# geos | |
ENV GEOS_VERSION=3.10.2 | |
RUN mkdir /tmp/geos \ | |
&& curl -sfL https://github.com/libgeos/geos/archive/refs/tags/${GEOS_VERSION}.tar.gz | tar zxf - -C /tmp/geos --strip-components=1 \ | |
&& cd /tmp/geos \ | |
&& mkdir build && cd build \ | |
&& cmake3 .. \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
-DCMAKE_INSTALL_LIBDIR:PATH=lib \ | |
-DCMAKE_C_FLAGS="-O2 -Wl,-S" \ | |
-DCMAKE_CXX_FLAGS="-O2 -Wl,-S" \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/geos | |
# proj | |
# We still provide proj-datumgrid but the user can choose to set `PROJ_NETWORK=ON` to use network grids | |
ENV PROJ_VERSION=8.2.1 | |
RUN mkdir /tmp/proj && mkdir /tmp/proj/data \ | |
&& curl -sfL https://github.com/OSGeo/proj/archive/${PROJ_VERSION}.tar.gz | tar zxf - -C /tmp/proj --strip-components=1 \ | |
&& curl -sfL http://download.osgeo.org/proj/proj-datumgrid-latest.tar.gz | tar zxf - -C /tmp/proj/data \ | |
&& cd /tmp/proj \ | |
&& aclocal && autoheader && libtoolize --force --copy && automake --add-missing --copy && autoconf \ | |
&& LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'" CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --disable-static --enable-lto \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/proj | |
# GeoTIFF | |
ENV LIBGEOTIFF_VERSION=1.6.0 | |
RUN mkdir /tmp/libgeotiff \ | |
&& curl -sfL https://github.com/OSGeo/libgeotiff/releases/download/${LIBGEOTIFF_VERSION}/libgeotiff-${LIBGEOTIFF_VERSION}.tar.gz | tar zxf - -C /tmp/libgeotiff --strip-components=1 \ | |
&& cd /tmp/libgeotiff \ | |
&& LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'" CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure \ | |
--prefix=$PREFIX \ | |
--with-proj=$PREFIX \ | |
--with-jpeg=$PREFIX \ | |
--with-zip=yes \ | |
--with-zlib \ | |
--with-libtiff=$PREFIX \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/libgeotiff | |
# gdal | |
RUN mkdir /tmp/gdal \ | |
&& curl -sfL https://github.com/OSGeo/gdal/archive/release/3.5.tar.gz | tar zxf - -C /tmp/gdal --strip-components=1 | |
RUN cd /tmp/gdal \ | |
&& mkdir build && cd build \ | |
&& cmake3 .. \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
-DCMAKE_INSTALL_LIBDIR:PATH=lib \ | |
-DCMAKE_C_FLAGS="-O2 -Wl,-S" \ | |
-DCMAKE_CXX_FLAGS="-O2 -Wl,-S" \ | |
-DGDAL_SET_INSTALL_RELATIVE_RPATH=ON \ | |
-DGDAL_USE_TIFF_INTERNAL=OFF \ | |
-DGDAL_USE_GEOTIFF_INTERNAL=OFF \ | |
-DGDAL_USE_LERC_INTERNAL=OFF \ | |
-DLERC_INCLUDE_DIR=$PREFIX/include \ | |
-DLERC_LIBRARY=$PREFIX/lib/libLercLib.so \ | |
-DPNG_PNG_INCLUDE_DIR=$PREFIX/include \ | |
-DPNG_LIBRARY_RELEASE=$PREFIX/lib/libpng.so \ | |
-DBUILD_PYTHON_BINDINGS=OFF \ | |
&& make -j $(nproc) --silent && make install \ | |
&& rm -rf /tmp/gdal | |
# from https://github.com/pypa/manylinux/blob/d8ef5d47433ba771fa4403fd48f352c586e06e43/docker/build_scripts/build.sh#L133-L138 | |
# Install patchelf (latest with unreleased bug fixes) | |
ENV PATCHELF_VERSION=0.10 | |
RUN mkdir /tmp/patchelf \ | |
&& curl -sfL https://github.com/NixOS/patchelf/archive/${PATCHELF_VERSION}.tar.gz | tar zxf - -C /tmp/patchelf --strip-components=1 \ | |
&& cd /tmp/patchelf && ./bootstrap.sh && ./configure \ | |
&& make -j $(nproc) --silent && make install \ | |
&& cd / && rm -rf /tmp/patchelf | |
# # libturbojpeg.so is not used by GDAL. Only libjpeg.so* | |
RUN rm -f $PREFIX/lib/libturbojpeg.so* \ | |
# Only libwebp.so is used by GDAL | |
&& rm -f $PREFIX/lib/libwebpmux.so* $PREFIX/lib/libwebpdemux.so* $PREFIX/lib/libwebpdecoder.so* | |
# FIX | |
RUN for i in $PREFIX/bin/*; do patchelf --force-rpath --set-rpath '$ORIGIN/../lib' $i; done | |
FROM public.ecr.aws/lambda/python:3.9 as lambda | |
ENV \ | |
LANG=en_US.UTF-8 \ | |
LC_ALL=en_US.UTF-8 \ | |
CFLAGS="--std=c99" | |
RUN yum install -y gcc gcc-c++ | |
RUN \ | |
python -m pip install pip -U \ | |
&& python -m pip install cython numpy --no-binary numpy | |
# The PREFIX should be the same as in gdal{version}:latest | |
# When building rasterio, setup.py will get libs directoy from gdal-config | |
# $ gdal-config --libs | |
# -L/opt/lib -lgdal | |
ENV PREFIX /opt | |
COPY --from=builder /opt/lib/ $PREFIX/lib/ | |
COPY --from=builder /opt/include/ $PREFIX/include/ | |
COPY --from=builder /opt/share/ $PREFIX/share/ | |
COPY --from=builder /opt/bin/ $PREFIX/bin/ | |
ENV \ | |
GDAL_DATA=$PREFIX/share/gdal \ | |
PROJ_LIB=$PREFIX/share/proj \ | |
GDAL_CONFIG=$PREFIX/bin/gdal-config \ | |
GEOS_CONFIG=$PREFIX/bin/geos-config \ | |
PATH=$PREFIX/bin:$PATH | |
RUN export GDAL_VERSION=$(gdal-config --version) | |
RUN python -m pip install rasterio==1.3b1 --no-binary | |
ENTRYPOINT bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment