Skip to content

Commit e2390ed

Browse files
committed
Build the GDAL base image and the geoserver images on top of it
1 parent 677fb88 commit e2390ed

File tree

20 files changed

+140
-67
lines changed

20 files changed

+140
-67
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66
branches:
77
- main
88
- "release/**"
9+
- "docker-gdal"
910
paths:
1011
- "Makefile"
1112
- "pom.xml"
1213
- ".github/workflows/build-and-push.yaml"
1314
- "config"
1415
- "src/**"
16+
- "docker-build/**"
1517
tags:
1618
- '*'
1719

@@ -20,7 +22,7 @@ jobs:
2022
if: github.repository == 'geoserver/geoserver-cloud'
2123
name: Build and Push
2224
runs-on: ubuntu-latest
23-
timeout-minutes: 60
25+
timeout-minutes: 120
2426
steps:
2527
- name: Login to Docker Hub
2628
uses: docker/login-action@v3
@@ -35,7 +37,6 @@ jobs:
3537

3638
- name: Set up Docker Buildx
3739
uses: docker/setup-buildx-action@v3
38-
# https://github.com/docker/setup-buildx-action
3940
with:
4041
platforms: linux/amd64,linux/arm64
4142
# Sets up docker build command as an alias to docker buildx

.github/workflows/build.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ name: Build on any branch
44
on:
55
push:
66
branches:
7-
- '**'
8-
- "!main"
7+
- "feature/**"
8+
- "bug/**"
9+
- "build/**"
910
paths:
1011
- "Makefile"
1112
- "pom.xml"
Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
11
services:
2-
base-image-jre:
2+
# Base JRE image, ubuntu 24.04, jre 21 temurin
3+
jre:
34
extends:
45
file: templates.yml
56
service: multi-platform
6-
image: ${REPOSITORY}/gs-cloud-base-jre:${TAG}
7+
image: ${REPOSITORY}/jre:21-tem
78
build:
89
context: ../src/apps/base-images/jre/
910

10-
base-image-spring-boot:
11+
# Base JRE image with libgdal-java
12+
jre-gdal:
1113
extends:
1214
file: templates.yml
1315
service: multi-platform
14-
image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG}
15-
depends_on: [base-image-jre]
16+
image: ${REPOSITORY}/jre-gdal:21-3.8.4
17+
depends_on: [jre]
18+
build:
19+
context: ../src/apps/base-images/gdal/
20+
args:
21+
JRE_BASE_IMAGE_NAME: jre:21-tem
22+
23+
# Base JRE + Spring Boot common layer for infra services
24+
spring-boot-common:
25+
extends:
26+
file: templates.yml
27+
service: multi-platform
28+
image: ${REPOSITORY}/spring-boot-common:${TAG}
29+
depends_on: [jre]
30+
build:
31+
context: ../src/apps/base-images/spring-boot/
32+
args:
33+
JRE_BASE_IMAGE_NAME: jre:21-tem
34+
35+
# Base JRE + GDAL + Spring Boot common layer for GeoServer services
36+
spring-boot-common-gdal:
37+
extends:
38+
file: templates.yml
39+
service: multi-platform
40+
image: ${REPOSITORY}/spring-boot-common-gdal:${TAG}
41+
depends_on: [jre-gdal]
1642
build:
1743
context: ../src/apps/base-images/spring-boot/
44+
args:
45+
JRE_BASE_IMAGE_NAME: jre-gdal:21-3.8.4
1846

19-
base-image-geoserver:
47+
# Base JRE + GDAL + Spring Boot + shared GeoServer dependencies layer for GeoServer services
48+
geoserver-common:
2049
extends:
2150
file: templates.yml
2251
service: multi-platform
23-
image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG}
24-
depends_on: [base-image-spring-boot]
52+
image: ${REPOSITORY}/geoserver-common:${TAG}
53+
depends_on: [spring-boot-common-gdal]
2554
build:
2655
context: ../src/apps/base-images/geoserver/

docker-build/base-images.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
11
services:
2-
base-image-jre:
2+
# Base JRE image, ubuntu 24.04, jre 21 temurin
3+
jre:
34
extends:
45
file: templates.yml
56
service: current-platform
6-
image: ${REPOSITORY}/gs-cloud-base-jre:${TAG}
7+
image: ${REPOSITORY}/jre:21-tem
78
build:
89
context: ../src/apps/base-images/jre/
910

10-
base-image-spring-boot:
11+
# Base JRE image with libgdal-java
12+
jre-gdal:
1113
extends:
1214
file: templates.yml
1315
service: current-platform
14-
image: ${REPOSITORY}/gs-cloud-base-spring-boot:${TAG}
15-
depends_on: [base-image-jre]
16+
image: ${REPOSITORY}/jre-gdal:21-3.8.4
17+
depends_on: [jre]
18+
build:
19+
context: ../src/apps/base-images/gdal/
20+
args:
21+
JRE_BASE_IMAGE_NAME: jre:21-tem
22+
23+
# Base JRE + Spring Boot common layer for infra services
24+
spring-boot-common:
25+
extends:
26+
file: templates.yml
27+
service: current-platform
28+
image: ${REPOSITORY}/spring-boot-common:${TAG}
29+
depends_on: [jre]
30+
build:
31+
context: ../src/apps/base-images/spring-boot/
32+
args:
33+
JRE_BASE_IMAGE_NAME: jre:21-tem
34+
35+
# Base JRE + GDAL + Spring Boot common layer for GeoServer services
36+
spring-boot-common-gdal:
37+
extends:
38+
file: templates.yml
39+
service: current-platform
40+
image: ${REPOSITORY}/spring-boot-common-gdal:${TAG}
41+
depends_on: [jre-gdal]
1642
build:
1743
context: ../src/apps/base-images/spring-boot/
44+
args:
45+
JRE_BASE_IMAGE_NAME: jre-gdal:21-3.8.4
1846

19-
base-image-geoserver:
47+
# Base JRE + GDAL + Spring Boot + shared GeoServer dependencies layer for GeoServer services
48+
geoserver-common:
2049
extends:
2150
file: templates.yml
2251
service: current-platform
23-
image: ${REPOSITORY}/gs-cloud-base-geoserver-image:${TAG}
24-
depends_on: [base-image-spring-boot]
52+
image: ${REPOSITORY}/geoserver-common:${TAG}
53+
depends_on: [spring-boot-common-gdal]
2554
build:
2655
context: ../src/apps/base-images/geoserver/

docker-build/templates.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
current-platform:
33
build:
44
no_cache: true
5-
pull: true
5+
#pull: true
66
context: override-me
77
args:
88
TAG: ${TAG}
@@ -11,7 +11,7 @@ services:
1111
multi-platform:
1212
build:
1313
no_cache: true
14-
pull: true
14+
#pull: true
1515
context: override-me
1616
platforms:
1717
- linux/amd64

src/apps/base-images/gdal/Dockerfile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#FROM geoservercloud/gs-cloud-base-jre:$TAG as builder
2-
FROM eclipse-temurin:11-jdk as builder
1+
ARG REPOSITORY=geoservercloud
2+
ARG JRE_BASE_IMAGE_NAME=jre:21-tem
3+
ARG TAG=latest
34

4-
LABEL maintainer="GeoServer PSC <geoserver-users@lists.sourceforge.net>"
5+
# Build with java 11
6+
FROM eclipse-temurin:11-jdk as builder
57

68
ENV GDAL_VERSION 3.8.4
79
ENV GDAL_PATH /usr/share/gdal
@@ -24,5 +26,21 @@ RUN wget https://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.ta
2426
sed -i 's/target="7"/target="8"/' /tmp/gdal-${GDAL_VERSION}/swig/java/build.xml
2527
RUN cd /tmp/gdal-${GDAL_VERSION} && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . --target install
2628

27-
RUN cp /tmp/gdal-3.8.4/build/swig/java/gdal.jar /tmp/gdal.jar
28-
RUN cp /tmp/gdal-3.8.4/build/swig/java/libgdalalljni.so /tmp/libgdalalljni.so
29+
RUN mkdir /tmp/gdal-java
30+
RUN cp /tmp/gdal-3.8.4/build/swig/java/gdal.jar /tmp/gdal-java/gdal.jar
31+
RUN cp /tmp/gdal-3.8.4/build/swig/java/libgdalalljni.so /tmp/gdal-java/libgdalalljni.so
32+
33+
##########
34+
FROM $REPOSITORY/$JRE_BASE_IMAGE_NAME
35+
36+
ENV GDAL_PATH /usr/share/gdal
37+
ENV GDAL_DATA $GDAL_PATH
38+
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$GDAL_PATH/lib:/usr/local/lib/:/usr/lib/
39+
40+
# see https://docs.docker.com/build/cache/optimize/#use-cache-mounts
41+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
42+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
43+
apt update && apt-get --no-install-recommends install -y gdal-bin \
44+
&& mkdir $GDAL_PATH/lib
45+
46+
COPY --from=builder /tmp/gdal-java/* $GDAL_PATH/lib/

src/apps/base-images/geoserver/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
ARG REPOSITORY=geoservercloud
22
ARG TAG=latest
33

4-
FROM $REPOSITORY/gs-cloud-base-jre:$TAG AS builder
4+
FROM eclipse-temurin:21-jre-noble AS builder
5+
56
ARG JAR_FILE=target/gs-cloud-*-bin.jar
67

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

1718
##########
18-
FROM $REPOSITORY/gs-cloud-base-spring-boot:$TAG
19+
FROM $REPOSITORY/spring-boot-common-gdal:$TAG
1920

2021
# init
2122
RUN apt update \

src/apps/base-images/jre/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM eclipse-temurin:21-jre
1+
# JRE 21 on Ubuntu 24.04
2+
FROM eclipse-temurin:21-jre-noble
23

34
LABEL maintainer="GeoServer PSC <geoserver-users@lists.sourceforge.net>"
45

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
ARG REPOSITORY=geoservercloud
2+
ARG JRE_BASE_IMAGE_NAME=jre:21-tem
23
ARG TAG=latest
34

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

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

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

1213
##########
13-
FROM $REPOSITORY/gs-cloud-base-jre:$TAG
14+
FROM $REPOSITORY/$JRE_BASE_IMAGE_NAME
1415

1516
COPY target/config/ /etc/geoserver/
1617

1718
RUN mkdir -p /opt/app/bin
1819

1920
WORKDIR /opt/app/bin
2021

21-
ENV JAVA_TOOL_OPTS="\
22-
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED \
23-
--add-opens=java.base/java.lang=ALL-UNNAMED \
24-
--add-opens=java.base/java.util=ALL-UNNAMED \
25-
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
26-
--add-opens=java.base/java.text=ALL-UNNAMED \
27-
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED \
28-
--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED \
29-
--add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED \
30-
-Djava.awt.headless=true"
31-
32-
ENV JAVA_OPTS=
3322
EXPOSE 8080
3423
EXPOSE 8081
3524

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

47-
CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS $JAVA_TOOL_OPTS org.springframework.boot.loader.JarLauncher
36+
CMD exec env USER_ID="$(id -u)" USER_GID="$(id -g)" java $JAVA_OPTS org.springframework.boot.loader.JarLauncher

src/apps/geoserver/gwc/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG REPOSITORY=geoservercloud
22
ARG TAG=latest
33

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

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

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

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

1515
# WORKDIR already set to /opt/app/bin
1616

0 commit comments

Comments
 (0)