Skip to content

Commit

Permalink
Docker: add options to add Oracle, ECW, MrSID drivers to ubuntu-full …
Browse files Browse the repository at this point in the history
…amd64
  • Loading branch information
rouault committed Nov 27, 2024
1 parent 1e3a6d5 commit a8d8bf5
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 21 deletions.
42 changes: 27 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,31 @@ jobs:
fail-fast: false
matrix:
include:
- name: alpine-small
arch: linux/amd64
- name: alpine-small-amd64
image_name: alpine-small
arch: amd64

- name: alpine-normal
arch: linux/amd64
- name: alpine-normal-amd64
image_name: alpine-small
arch: amd64

- name: ubuntu-small
arch: linux/amd64
- name: ubuntu-small-amd64
image_name: ubuntu-small
arch: amd64

- name: ubuntu-small
arch: linux/arm64
- name: ubuntu-small-arm64
image_name: ubuntu-small
arch: arm64

- name: ubuntu-full
arch: linux/amd64
- name: ubuntu-full-amd64-proprietary-sdks
image_name: ubuntu-full
arch: amd64

- name: ubuntu-full
arch: linux/arm64
- name: ubuntu-full-arm64
image_name: ubuntu-full
arch: arm64

name: ${{ matrix.name }}-${{ matrix.arch }}
name: ${{ matrix.name }}

runs-on: ubuntu-latest

Expand All @@ -54,5 +60,11 @@ jobs:
shell: bash -l {0}
run: |
docker run --rm --privileged linuxkit/binfmt:v0.8
cd docker/${{ matrix.name }}
./build.sh --platform ${{ matrix.arch }}
cd docker/${{ matrix.image_name }}
if test "${{ matrix.name }}" = "ubuntu-full-amd64-proprietary-sdks"; then
./build.sh --platform linux/${{ matrix.arch }} --with-oracle --with-mrsid --with-ecw
else
./build.sh --platform linux/${{ matrix.arch }}
fi
docker run --rm -it ghcr.io/osgeo/gdal:${{ matrix.image_name }}-latest-${{ matrix.arch }} gdalinfo --formats
docker run --rm -it ghcr.io/osgeo/gdal:${{ matrix.image_name }}-latest-${{ matrix.arch }} ogrinfo --formats
10 changes: 10 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@ Override the image and repository of the final image by setting the environment
**Example**

`TARGET_IMAGE="YOU_DOCKER_USERNAME/gdal" alpine-small/build.sh --release --gdal v3.2.0 --proj master`

## Drivers based on proprietary software development kits

For the `ubuntu-full` amd64 image,

* The OCI and GeoRaster based drivers can be enabled by passing ``--with-oracle`` to util.sh
* The ECW and JP2ECW drivers can be enabled by passing ``--with-ecw`` to util.sh
* The MrSID driver can be enabled by passing ``--with-mrsid`` to util.sh

Note: those are not enabled in the official images provided by the project.
80 changes: 74 additions & 6 deletions docker/ubuntu-full/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ RUN --mount=type=cache,id=ubuntu-full-libopendrive,target=$HOME/.cache \
&& rm -rf libOpenDRIVE-${OPENDRIVE_VERSION} \
); fi

#Build File Geodatabase

#Build File Geodatabase if WITH_FILEGDB=yes is passed
ARG WITH_FILEGDB=
RUN . /buildscripts/bh-set-envvars.sh \
&& if echo "$WITH_FILEGDB" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
Expand All @@ -293,6 +292,57 @@ RUN . /buildscripts/bh-set-envvars.sh \
&& rm -rf FileGDB_API-RHEL7-64gcc83.tar.gz \
) ; fi

# Download Oracle InstantClient (proprietary) SDK if WITH_ORACLE=yes is passed
ARG WITH_ORACLE=
RUN . /buildscripts/bh-set-envvars.sh \
&& if test "$(uname -p)" = "x86_64"; then \
if echo "$WITH_ORACLE" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-basic-linux.x64-19.23.0.0.0dbru.zip \
&& wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip \
&& unzip -o instantclient-basic-linux.x64-19.23.0.0.0dbru.zip \
&& unzip -o instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip \
&& rm -f instantclient-basic-linux.x64-19.23.0.0.0dbru.zip instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip \
&& mv instantclient_19_23 /opt \
&& mkdir -p /build_thirdparty/opt \
&& cp -r /opt/instantclient_19_23 /build_thirdparty/opt \
&& (cd /opt/instantclient_19_23; for i in *.so*; do ln -s /opt/instantclient_19_23/$i /usr/lib/x86_64-linux-gnu; ln -s /opt/instantclient_19_23/$i /build_thirdparty/usr/lib/x86_64-linux-gnu; done) \
) ; fi \
; fi

# Download ECW (proprietary) SDK if WITH_ECW=yes is passed
ARG WITH_ECW=
RUN . /buildscripts/bh-set-envvars.sh \
&& if test "$(uname -p)" = "x86_64"; then \
if echo "$WITH_ECW" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
wget https://github.com/rouault/libecwj2-3.3-builds/releases/download/v1/install-libecwj2-3.3-ubuntu-20.04.tar.gz \
&& tar xzf install-libecwj2-3.3-ubuntu-20.04.tar.gz \
&& rm -f install-libecwj2-3.3-ubuntu-20.04.tar.gz \
&& mkdir -p /build_thirdparty/opt \
&& cp -r /opt/libecwj2-3.3 /build_thirdparty/opt \
&& (cd /opt/libecwj2-3.3/lib; for i in *.so*; do ln -s /opt/libecwj2-3.3/lib/$i /usr/lib/x86_64-linux-gnu; ln -s /opt/libecwj2-3.3/lib/$i /build_thirdparty/usr/lib/x86_64-linux-gnu; done) \
) ; fi \
; fi

# Download MrSID (proprietary) SDK if WITH_MRSID=yes is passed
ARG WITH_MRSID=
RUN . /buildscripts/bh-set-envvars.sh \
&& if test "$(uname -p)" = "x86_64"; then \
if echo "$WITH_MRSID" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
wget https://bin.extensis.com/download/developer/MrSID_DSDK-9.5.5.5244-rhel9.x86-64.gcc1131.zip \
&& unzip MrSID_DSDK-9.5.5.5244-rhel9.x86-64.gcc1131.zip \
&& mv MrSID_DSDK-9.5.5.5244-rhel9.x86-64.gcc1131 mrsid \
&& rm -f MrSID_DSDK-9.5.5.5244-rhel9.x86-64.gcc1131.zip \
&& mkdir -p /opt/Raster_DSDK/include \
&& mkdir -p /opt/Raster_DSDK/lib \
&& cp -r mrsid/Raster_DSDK/include/* /opt/Raster_DSDK/include \
&& cp -r mrsid/Raster_DSDK/lib/* /opt/Raster_DSDK/lib \
&& rm -rf mrsid \
&& mkdir -p /build_thirdparty/opt/Raster_DSDK/lib \
&& cp -r /opt/Raster_DSDK/lib /build_thirdparty/opt/Raster_DSDK \
&& (cd /opt/Raster_DSDK/lib; for i in *.so*; do ln -s /opt/Raster_DSDK/lib/$i /usr/lib/x86_64-linux-gnu; ln -s /opt/Raster_DSDK/lib/$i /build_thirdparty/usr/lib/x86_64-linux-gnu; done) \
) ; fi \
; fi

# Build libqb3
RUN --mount=type=cache,id=ubuntu-full-libqb3,target=$HOME/.cache \
. /buildscripts/bh-set-envvars.sh \
Expand Down Expand Up @@ -425,11 +475,17 @@ COPY ./bh-proj.sh /buildscripts/bh-proj.sh
# We want 2 separate steps for incremental builds where grids are refreshed
# only when the content of cdn.proj.org has changed, independently if PROJ master
# itself has changed.
ARG WITH_PROJ_GRIDS=yes
RUN --mount=type=cache,id=ubuntu-full-proj,target=$HOME/.cache \
. /buildscripts/bh-set-envvars.sh \
&& DESTDIR=/build_tmp_proj /buildscripts/bh-proj.sh \
&& LD_LIBRARY_PATH=/build_tmp_proj/usr/local/lib /build_tmp_proj/usr/local/bin/projsync --target-dir /tmp/proj_grids --all \
&& rm -rf /build_tmp_proj
mkdir -p /tmp/proj_grids \
&& touch /tmp/proj_grids/proj_grids_not_included \
&& if echo "$WITH_PROJ_GRIDS" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
. /buildscripts/bh-set-envvars.sh \
&& rm -f /tmp/proj_grids/proj_grids_not_included \
&& DESTDIR=/build_tmp_proj /buildscripts/bh-proj.sh \
&& LD_LIBRARY_PATH=/build_tmp_proj/usr/local/lib /build_tmp_proj/usr/local/bin/projsync --target-dir /tmp/proj_grids --all \
&& rm -rf /build_tmp_proj \
); fi

# Build PROJ
ARG PROJ_VERSION=master
Expand All @@ -448,6 +504,8 @@ RUN --mount=type=cache,id=ubuntu-full-gdal,target=$HOME/.cache \
. /buildscripts/bh-set-envvars.sh \
&& /buildscripts/bh-gdal.sh

RUN mkdir -p /build_thirdparty/opt

# Build final image
FROM $TARGET_BASE_IMAGE AS runner

Expand Down Expand Up @@ -526,9 +584,19 @@ RUN if test "$(uname -p)" = "x86_64"; then \
&& rm -f libduckdb-linux-amd64.zip; \
fi

ARG WITH_ORACLE=
RUN if test "$(uname -p)" = "x86_64"; then \
if echo "$WITH_ORACLE" | grep -Eiq "^(y(es)?|1|true)$" ; then ( \
apt-get update \
&& apt-get install -y -V libaio1t64 \
&& ln -s libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1 \
) ; fi \
; fi

# Attempt to order layers starting with less frequently varying ones

COPY --from=builder /build_thirdparty/usr/ /usr/
COPY --from=builder /build_thirdparty/opt/ /opt/

ARG PROJ_INSTALL_PREFIX=/usr/local
COPY --from=builder /tmp/proj_grids/* ${PROJ_INSTALL_PREFIX}/share/proj/
Expand Down
11 changes: 11 additions & 0 deletions docker/ubuntu-full/bh-gdal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ wget -q "https://github.com/${GDAL_REPOSITORY}/archive/${GDAL_VERSION}.tar.gz" \
export GDAL_CMAKE_EXTRA_OPTS="${GDAL_CMAKE_EXTRA_OPTS} -DFileGDB_ROOT:PATH=/usr/local/FileGDB_API -DFileGDB_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libFileGDBAPI.so"
export LD_LIBRARY_PATH=/usr/local/FileGDB_API/lib:${LD_LIBRARY_PATH:-}
fi
if test "$(uname -p)" = "x86_64"; then
if echo "$WITH_ORACLE" | grep -Eiq "^(y(es)?|1|true)$" ; then
export GDAL_CMAKE_EXTRA_OPTS="${GDAL_CMAKE_EXTRA_OPTS} -DOracle_ROOT=/opt/instantclient_19_23"
fi
if echo "$WITH_ECW" | grep -Eiq "^(y(es)?|1|true)$" ; then
export GDAL_CMAKE_EXTRA_OPTS="${GDAL_CMAKE_EXTRA_OPTS} -DECW_ROOT=/opt/libecwj2-3.3"
fi
if echo "$WITH_MRSID" | grep -Eiq "^(y(es)?|1|true)$" ; then
export GDAL_CMAKE_EXTRA_OPTS="${GDAL_CMAKE_EXTRA_OPTS} -DMRSID_ROOT=/opt/Raster_DSDK"
fi
fi
echo "${GDAL_CMAKE_EXTRA_OPTS}"
cmake .. \
-G Ninja \
Expand Down
34 changes: 34 additions & 0 deletions docker/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ usage()
echo "--docker-cache/--no-docker-cache: instruct Docker to build with/without using its cache. Defaults to no cache for release builds."
echo "--no-rsync-daemon: do not use the rsync daemon to save build cache in home directory."
echo "--with-debug-symbols/--without-debug-symbols. Whether to include debug symbols. Only applies to ubuntu-full, default is to include for non-release builds."
echo "--with-oracle: Whether to include Oracle Instant Client proprietary SDK"
echo "--with-ecw: Whether to include ECW proprietary SDK"
echo "--with-mrsid: Whether to include MrSID proprietary SDK"
exit 1
}

Expand Down Expand Up @@ -126,6 +129,21 @@ do
shift
;;

--with-oracle)
WITH_ORACLE=yes
shift
;;

--with-ecw)
WITH_ECW=yes
shift
;;

--with-mrsid)
WITH_MRSID=yes
shift
;;

# Unknown option
*)
echo "Unrecognized option: $1"
Expand Down Expand Up @@ -221,6 +239,22 @@ BUILD_ARGS=(
)
[ -z "${DOCKER_CACHE_PARAM}" ] || BUILD_ARGS+=("${DOCKER_CACHE_PARAM}")

if test "${WITH_ORACLE}" != ""; then
BUILD_ARGS+=("--build-arg" "WITH_ORACLE=${WITH_ORACLE}")
fi

if test "${WITH_ECW}" != ""; then
BUILD_ARGS+=("--build-arg" "WITH_ECW=${WITH_ECW}")
fi

if test "${WITH_MRSID}" != ""; then
BUILD_ARGS+=("--build-arg" "WITH_MRSID=${WITH_MRSID}")
fi

if test "${WITH_PROJ_GRIDS}" != ""; then
BUILD_ARGS+=("--build-arg" "$WITH_PROJ_GRIDS=${WITH_PROJ_GRIDS}")
fi

if test "${RELEASE}" = "yes"; then
BUILD_ARGS+=("--build-arg" "GDAL_BUILD_IS_RELEASE=YES")

Expand Down

0 comments on commit a8d8bf5

Please sign in to comment.