Skip to content

Commit

Permalink
Build the GDAL base image and the geoserver images on top of it
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Oct 10, 2024
1 parent 677fb88 commit 8e63fa7
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 63 deletions.
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
28 changes: 23 additions & 5 deletions src/apps/base-images/gdal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#FROM geoservercloud/gs-cloud-base-jre:$TAG as builder
FROM eclipse-temurin:11-jdk as builder
ARG REPOSITORY=geoservercloud
ARG JRE_BASE_IMAGE_NAME=jre:21-tem
ARG TAG=latest

LABEL maintainer="GeoServer PSC <[email protected]>"
# Build with java 11
FROM eclipse-temurin:11-jdk as builder

ENV GDAL_VERSION 3.8.4
ENV GDAL_PATH /usr/share/gdal
Expand All @@ -24,5 +26,21 @@ RUN wget https://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.ta
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 cp /tmp/gdal-3.8.4/build/swig/java/gdal.jar /tmp/gdal.jar
RUN cp /tmp/gdal-3.8.4/build/swig/java/libgdalalljni.so /tmp/libgdalalljni.so
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/
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
4 changes: 2 additions & 2 deletions src/apps/geoserver/webui/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/wfs/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/wms/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/wps/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
5 changes: 3 additions & 2 deletions src/apps/infrastructure/admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
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

COPY ${JAR_FILE} application.jar

RUN java -Djarmode=layertools -jar application.jar extract

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

# WORKDIR already set to /opt/app/bin

Expand Down
Loading

0 comments on commit 8e63fa7

Please sign in to comment.