Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDAL base docker image #538

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
branches:
- main
- "release/**"
- "docker-gdal"
paths:
- "Makefile"
- "pom.xml"
- ".github/workflows/build-and-push.yaml"
- "config"
- "src/**"
- "docker-build/**"
tags:
- '*'

Expand All @@ -20,7 +22,7 @@ jobs:
if: github.repository == 'geoserver/geoserver-cloud'
name: Build and Push
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 120
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -35,7 +37,6 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/docker/setup-buildx-action
with:
platforms: linux/amd64,linux/arm64
# Sets up docker build command as an alias to docker buildx
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ name: Build on any branch
on:
push:
branches:
- '**'
- "!main"
- "feature/**"
- "bug/**"
- "build/**"
paths:
- "Makefile"
- "pom.xml"
Expand Down
45 changes: 37 additions & 8 deletions docker-build/base-images-multiplatform.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
services:
base-image-jre:
# Base JRE image, ubuntu 24.04, jre 21 temurin
jre:
extends:
file: templates.yml
service: multi-platform
image: ${REPOSITORY}/gs-cloud-base-jre:${TAG}
image: ${REPOSITORY}/jre:21-tem
build:
context: ../src/apps/base-images/jre/

base-image-spring-boot:
# Base JRE image with libgdal-java
jre-gdal:
extends:
file: templates.yml
service: multi-platform
image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG}
depends_on: [base-image-jre]
image: ${REPOSITORY}/jre-gdal:21-3.8.4
depends_on: [jre]
build:
context: ../src/apps/base-images/gdal/
args:
JRE_BASE_IMAGE_NAME: jre:21-tem

# Base JRE + Spring Boot common layer for infra services
spring-boot-common:
extends:
file: templates.yml
service: multi-platform
image: ${REPOSITORY}/spring-boot-common:${TAG}
depends_on: [jre]
build:
context: ../src/apps/base-images/spring-boot/
args:
JRE_BASE_IMAGE_NAME: jre:21-tem

# Base JRE + GDAL + Spring Boot common layer for GeoServer services
spring-boot-common-gdal:
extends:
file: templates.yml
service: multi-platform
image: ${REPOSITORY}/spring-boot-common-gdal:${TAG}
depends_on: [jre-gdal]
build:
context: ../src/apps/base-images/spring-boot/
args:
JRE_BASE_IMAGE_NAME: jre-gdal:21-3.8.4

base-image-geoserver:
# Base JRE + GDAL + Spring Boot + shared GeoServer dependencies layer for GeoServer services
geoserver-common:
extends:
file: templates.yml
service: multi-platform
image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG}
depends_on: [base-image-spring-boot]
image: ${REPOSITORY}/geoserver-common:${TAG}
depends_on: [spring-boot-common-gdal]
build:
context: ../src/apps/base-images/geoserver/
45 changes: 37 additions & 8 deletions docker-build/base-images.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
services:
base-image-jre:
# Base JRE image, ubuntu 24.04, jre 21 temurin
jre:
extends:
file: templates.yml
service: current-platform
image: ${REPOSITORY}/gs-cloud-base-jre:${TAG}
image: ${REPOSITORY}/jre:21-tem
build:
context: ../src/apps/base-images/jre/

base-image-spring-boot:
# Base JRE image with libgdal-java
jre-gdal:
extends:
file: templates.yml
service: current-platform
image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG}
depends_on: [base-image-jre]
image: ${REPOSITORY}/jre-gdal:21-3.8.4
depends_on: [jre]
build:
context: ../src/apps/base-images/gdal/
args:
JRE_BASE_IMAGE_NAME: jre:21-tem

# Base JRE + Spring Boot common layer for infra services
spring-boot-common:
extends:
file: templates.yml
service: current-platform
image: ${REPOSITORY}/spring-boot-common:${TAG}
depends_on: [jre]
build:
context: ../src/apps/base-images/spring-boot/
args:
JRE_BASE_IMAGE_NAME: jre:21-tem

# Base JRE + GDAL + Spring Boot common layer for GeoServer services
spring-boot-common-gdal:
extends:
file: templates.yml
service: current-platform
image: ${REPOSITORY}/spring-boot-common-gdal:${TAG}
depends_on: [jre-gdal]
build:
context: ../src/apps/base-images/spring-boot/
args:
JRE_BASE_IMAGE_NAME: jre-gdal:21-3.8.4

base-image-geoserver:
# Base JRE + GDAL + Spring Boot + shared GeoServer dependencies layer for GeoServer services
geoserver-common:
extends:
file: templates.yml
service: current-platform
image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG}
depends_on: [base-image-spring-boot]
image: ${REPOSITORY}/geoserver-common:${TAG}
depends_on: [spring-boot-common-gdal]
build:
context: ../src/apps/base-images/geoserver/
4 changes: 2 additions & 2 deletions docker-build/templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
current-platform:
build:
no_cache: true
pull: true
#pull: true
context: override-me
args:
TAG: ${TAG}
Expand All @@ -11,7 +11,7 @@ services:
multi-platform:
build:
no_cache: true
pull: true
#pull: true
context: override-me
platforms:
- linux/amd64
Expand Down
46 changes: 46 additions & 0 deletions src/apps/base-images/gdal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG REPOSITORY=geoservercloud
ARG JRE_BASE_IMAGE_NAME=jre:21-tem
ARG TAG=latest

# Build with java 11
FROM eclipse-temurin:11-jdk as builder

ENV GDAL_VERSION 3.8.4
ENV GDAL_PATH /usr/share/gdal
ENV GDAL_DATA $GDAL_PATH/3.8.4
ENV PATH $GDAL_PATH:$PATH
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/jni:/usr/share/java:/usr/local/lib/:/usr/lib/

#
# GDAL INSTALLATION
#
# Manual compilation - https://stackoverflow.com/questions/76913667/unable-to-locate-package-libgdal-java
RUN apt update && apt-get install -y wget build-essential libuv1-dev g++ libstdc++6 make linux-headers-generic \
libssl-dev swig zlib1g-dev proj-bin proj-data libproj-dev sqlite3 libsqlite3-dev \
libtiff-dev libcurl4-openssl-dev cmake libcrypto++-dev ant libeccodes-dev libnetcdf-dev
# Install GDAL
RUN wget https://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz -O /tmp/gdal.tar.gz && \
tar xzf /tmp/gdal.tar.gz -C /tmp && \
cd /tmp/gdal-${GDAL_VERSION} && \
sed -i 's/source="7"/source="8"/' /tmp/gdal-${GDAL_VERSION}/swig/java/build.xml && \
sed -i 's/target="7"/target="8"/' /tmp/gdal-${GDAL_VERSION}/swig/java/build.xml
RUN cd /tmp/gdal-${GDAL_VERSION} && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . --target install

RUN mkdir /tmp/gdal-java
RUN cp /tmp/gdal-3.8.4/build/swig/java/gdal.jar /tmp/gdal-java/gdal.jar
RUN cp /tmp/gdal-3.8.4/build/swig/java/libgdalalljni.so /tmp/gdal-java/libgdalalljni.so

##########
FROM $REPOSITORY/$JRE_BASE_IMAGE_NAME

ENV GDAL_PATH /usr/share/gdal
ENV GDAL_DATA $GDAL_PATH
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$GDAL_PATH/lib:/usr/local/lib/:/usr/lib/

# see https://docs.docker.com/build/cache/optimize/#use-cache-mounts
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y gdal-bin \
&& mkdir $GDAL_PATH/lib

COPY --from=builder /tmp/gdal-java/* $GDAL_PATH/lib/
24 changes: 24 additions & 0 deletions src/apps/base-images/gdal/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.geoserver.cloud.apps</groupId>
<artifactId>gs-cloud-base-images</artifactId>
<version>${revision}</version>
</parent>
<artifactId>gs-cloud-base-jre-gdal</artifactId>
<packaging>jar</packaging>
<name>Base GDAL image</name>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
5 changes: 3 additions & 2 deletions src/apps/base-images/geoserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG REPOSITORY=geoservercloud
ARG TAG=latest

FROM $REPOSITORY/gs-cloud-base-jre:$TAG AS builder
FROM eclipse-temurin:21-jre-noble AS builder

ARG JAR_FILE=target/gs-cloud-*-bin.jar

RUN apt update && apt install -y --no-install-recommends unzip
Expand All @@ -15,7 +16,7 @@ RUN java -Djarmode=layertools -jar application.jar extract
# rm /tmp/YourKit-JavaProfiler-2023.9-docker.zip

##########
FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG
FROM $REPOSITORY/spring-boot-common-gdal:$TAG

# init
RUN apt update \
Expand Down
3 changes: 2 additions & 1 deletion src/apps/base-images/jre/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM eclipse-temurin:21-jre
# JRE 21 on Ubuntu 24.04
FROM eclipse-temurin:21-jre-noble

LABEL maintainer="GeoServer PSC <[email protected]>"

Expand Down
19 changes: 4 additions & 15 deletions src/apps/base-images/spring-boot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG REPOSITORY=geoservercloud
ARG JRE_BASE_IMAGE_NAME=jre:21-tem
ARG TAG=latest

FROM $REPOSITORY/gs-cloud-base-jre:$TAG AS builder
FROM eclipse-temurin:21-jre-noble AS builder

ARG JAR_FILE=target/gs-cloud-*-bin.jar

Expand All @@ -10,26 +11,14 @@ COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

##########
FROM $REPOSITORY/gs-cloud-base-jre:$TAG
FROM $REPOSITORY/$JRE_BASE_IMAGE_NAME

COPY target/config/ /etc/geoserver/

RUN mkdir -p /opt/app/bin

WORKDIR /opt/app/bin

ENV JAVA_TOOL_OPTS="\
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.text=ALL-UNNAMED \
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED \
--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED \
--add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED \
-Djava.awt.headless=true"

ENV JAVA_OPTS=
EXPOSE 8080
EXPOSE 8081

Expand All @@ -44,4 +33,4 @@ HEALTHCHECK \
--retries=5 \
CMD curl -f -s -o /dev/null localhost:8081/actuator/health || exit 1

CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS $JAVA_TOOL_OPTS org.springframework.boot.loader.JarLauncher
CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS org.springframework.boot.loader.JarLauncher
4 changes: 2 additions & 2 deletions src/apps/geoserver/gwc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG REPOSITORY=geoservercloud
ARG TAG=latest

FROM $REPOSITORY/gs-cloud-base-jre:$TAG as builder
FROM eclipse-temurin:21-jre-noble AS builder

ARG JAR_FILE=target/gs-cloud-*-bin.jar

Expand All @@ -10,7 +10,7 @@ COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

##########
FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG
FROM $REPOSITORY/spring-boot-common-gdal:$TAG

# WORKDIR already set to /opt/app/bin

Expand Down
4 changes: 2 additions & 2 deletions src/apps/geoserver/restconfig/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG REPOSITORY=geoservercloud
ARG TAG=latest

FROM $REPOSITORY/gs-cloud-base-jre:$TAG as builder
FROM eclipse-temurin:21-jre-noble AS builder

ARG JAR_FILE=target/gs-cloud-*-bin.jar

Expand All @@ -10,7 +10,7 @@ COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

##########
FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG
FROM $REPOSITORY/spring-boot-common-gdal:$TAG

# WORKDIR already set to /opt/app/bin

Expand Down
4 changes: 2 additions & 2 deletions src/apps/geoserver/wcs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG REPOSITORY=geoservercloud
ARG TAG=latest

FROM $REPOSITORY/gs-cloud-base-jre:$TAG as builder
FROM eclipse-temurin:21-jre-noble AS builder

ARG JAR_FILE=target/gs-cloud-*-bin.jar

Expand All @@ -10,7 +10,7 @@ COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

##########
FROM $REPOSITORY/gs-cloud-base-geoserver-image:$TAG
FROM $REPOSITORY/spring-boot-common-gdal:$TAG

# WORKDIR already set to /opt/app/bin

Expand Down
Loading
Loading