-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ae6e45
commit 4d539f2
Showing
3 changed files
with
59 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,75 @@ | ||
## | ||
# andrejreznik/python-gdal | ||
# | ||
# Build args can be redefined in Makefile or passed as build args to Docker build command | ||
FROM debian:bookworm | ||
|
||
ARG BASE_IMAGE=python:3.10.0-slim-bullseye | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
LABEL maintainer="Andrii Rieznik <andrii.rieznik@protonmail.com>" | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/andriyreznik/docker-python-gdal | ||
LABEL org.opencontainers.image.authors=andrii.rieznik@pm.me | ||
LABEL org.opencontainers.image.source=https://github.com/andrii-reznik/docker-python-gdal | ||
LABEL org.opencontainers.image.description="Debian based image with pre-installed GDAL/OGR libraries and Python bindings" | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
ARG GDAL_VERSION=3.2.3 | ||
ARG PYTHON_VERSION=3.12.4 | ||
ARG GDAL_VERSION=3.9.1 | ||
ARG SOURCE_DIR=/usr/local/src/python-gdal | ||
|
||
ENV PYENV_ROOT="/usr/local/pyenv" | ||
ENV PATH="/usr/local/pyenv/shims:/usr/local/pyenv/bin:$PATH" | ||
|
||
RUN \ | ||
# Install runtime dependencies | ||
# Install runtime dependencies | ||
apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
wget \ | ||
automake libtool pkg-config libsqlite3-dev sqlite3 \ | ||
libpq-dev \ | ||
libcurl4-gnutls-dev \ | ||
libproj-dev \ | ||
git \ | ||
libssl-dev \ | ||
zlib1g-dev \ | ||
libbz2-dev \ | ||
libreadline-dev \ | ||
libsqlite3-dev \ | ||
libncursesw5-dev \ | ||
xz-utils \ | ||
tk-dev \ | ||
libxml2-dev \ | ||
libgeos-dev \ | ||
libnetcdf-dev \ | ||
libpoppler-dev \ | ||
libspatialite-dev \ | ||
libhdf4-alt-dev \ | ||
libhdf5-serial-dev \ | ||
libopenjp2-7-dev \ | ||
libxmlsec1-dev \ | ||
libffi-dev \ | ||
liblzma-dev \ | ||
ca-certificates \ | ||
\ | ||
curl \ | ||
cmake \ | ||
libproj-dev \ | ||
swig \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
\ | ||
# Install numpy | ||
&& pip install numpy \ | ||
# Build against PROJ master (which will be released as PROJ 6.0) | ||
&& wget "http://download.osgeo.org/proj/proj-6.0.0.tar.gz" \ | ||
&& tar -xzf "proj-6.0.0.tar.gz" \ | ||
&& mv proj-6.0.0 proj \ | ||
&& echo "#!/bin/sh" > proj/autogen.sh \ | ||
&& chmod +x proj/autogen.sh \ | ||
&& cd proj \ | ||
&& ./autogen.sh \ | ||
&& CXXFLAGS='-DPROJ_RENAME_SYMBOLS' CFLAGS='-DPROJ_RENAME_SYMBOLS' ./configure --disable-static --prefix=/usr/local \ | ||
&& make -j"$(nproc)" \ | ||
&& make -j"$(nproc)" install \ | ||
# Rename the library to libinternalproj | ||
&& mv /usr/local/lib/libproj.so.15.0.0 /usr/local/lib/libinternalproj.so.15.0.0 \ | ||
&& rm /usr/local/lib/libproj.so* \ | ||
&& rm /usr/local/lib/libproj.la \ | ||
&& ln -s libinternalproj.so.15.0.0 /usr/local/lib/libinternalproj.so.15 \ | ||
&& ln -s libinternalproj.so.15.0.0 /usr/local/lib/libinternalproj.so \ | ||
\ | ||
# Get latest GDAL source | ||
# Install pyenv | ||
&& git clone https://github.com/pyenv/pyenv.git ${PYENV_ROOT} \ | ||
&& echo 'export PYENV_ROOT=/usr/local/pyenv' >> /root/.bashrc \ | ||
&& echo 'export PATH=/usr/local/pyenv/bin:$PATH' >> /root/.bashrc \ | ||
&& echo 'eval "$(pyenv init -)"' >> /root/.bashrc \ | ||
&& eval "$(pyenv init -)" && pyenv install ${PYTHON_VERSION} \ | ||
&& eval "$(pyenv init -)" && pyenv global ${PYTHON_VERSION} \ | ||
&& eval "$(pyenv init -)" && pip install --upgrade pip \ | ||
&& eval "$(pyenv init -)" && pip install numpy setuptools \ | ||
# Install GDAL | ||
&& export CMAKE_BUILD_PARALLEL_LEVEL=`nproc --all` \ | ||
&& mkdir -p "${SOURCE_DIR}" \ | ||
&& cd "${SOURCE_DIR}" \ | ||
&& wget "http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz" \ | ||
&& tar -xvf "gdal-${GDAL_VERSION}.tar.gz" \ | ||
\ | ||
# Compile and install GDAL | ||
&& cd "gdal-${GDAL_VERSION}" \ | ||
&& export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH \ | ||
&& ./configure \ | ||
--with-python \ | ||
--with-curl \ | ||
--with-openjpeg \ | ||
--without-libtool \ | ||
--with-proj=/usr/local \ | ||
&& make -j"$(nproc)" \ | ||
&& make install \ | ||
&& cd gdal-${GDAL_VERSION} \ | ||
&& mkdir build \ | ||
&& cd build \ | ||
&& cmake .. \ | ||
-DBUILD_PYTHON_BINDINGS=ON \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DPYTHON_INCLUDE_DIR=`python -c "import sysconfig; print(sysconfig.get_path('include'))"` \ | ||
-DPYTHON_LIBRARY=`python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"` \ | ||
-DGDAL_PYTHON_INSTALL_PREFIX=`pyenv prefix` \ | ||
&& cmake --build . \ | ||
&& cmake --build . --target install \ | ||
&& ldconfig \ | ||
\ | ||
# Install Python bindings as standalone module via pip | ||
&& pip install GDAL==${GDAL_VERSION} \ | ||
&& cd /usr/local \ | ||
\ | ||
# Clean up | ||
# Clean-up | ||
&& apt-get update -y \ | ||
&& apt-get remove -y --purge build-essential wget \ | ||
&& apt-get autoremove -y \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf "${SOURCE_DIR}" | ||
|
||
CMD python3 -V && pip -V && gdalinfo --version | ||
CMD python -V && pip -V && gdalinfo --version |
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
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