Skip to content

Commit 8eb3da1

Browse files
Initial commit: GeoServer 2.25.3
0 parents  commit 8eb3da1

File tree

8 files changed

+342
-0
lines changed

8 files changed

+342
-0
lines changed

.github/workflows/build.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: Build / Test / Push
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
BUILD_SUFFIX: -build-${{ github.run_id }}_${{ github.run_attempt }}
12+
DOCKER_METADATA_SET_OUTPUT_ENV: 'true'
13+
14+
jobs:
15+
build:
16+
runs-on: ${{ matrix.runner }}
17+
outputs:
18+
build-image-arm: ${{ steps.gen-output.outputs.image-arm64 }}
19+
build-image-x64: ${{ steps.gen-output.outputs.image-x64 }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
runner:
24+
- ubuntu-24.04
25+
- ubuntu-24.04-arm
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- id: build-meta
41+
name: Docker meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ghcr.io/${{ github.repository }}
45+
tags: type=sha,suffix=${{ env.BUILD_SUFFIX }}
46+
47+
# Build cache is shared among all builds of the same architecture
48+
- id: cache-meta
49+
name: Docker meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ghcr.io/${{ github.repository }}
53+
tags: type=raw,value=buildcache-${{ runner.arch }}
54+
55+
- id: get-registry
56+
name: Get the sanitized registry name
57+
run: |
58+
echo "registry=$(echo '${{ steps.build-meta.outputs.tags }}' | cut -f1 -d:)" | tee -a "$GITHUB_OUTPUT"
59+
60+
- id: build
61+
name: Build/push the arch-specific image
62+
uses: docker/build-push-action@v6
63+
with:
64+
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
65+
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
66+
labels: ${{ steps.build-meta.outputs.labels }}
67+
provenance: mode=max
68+
sbom: true
69+
tags: ${{ steps.get-registry.outputs.registry }}
70+
outputs: type=image,push-by-digest=true,push=true
71+
72+
- id: gen-output
73+
name: Write arch-specific image digest to outputs
74+
run: |
75+
echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
76+
77+
merge:
78+
runs-on: ubuntu-24.04
79+
needs:
80+
- build
81+
env:
82+
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.build-image-arm }}
83+
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.build-image-x64 }}
84+
outputs:
85+
build-image: ${{ steps.meta.outputs.tags }}
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v4
89+
90+
- name: Set up Docker Buildx
91+
uses: docker/setup-buildx-action@v3
92+
93+
- name: Login to GitHub Container Registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: ghcr.io
97+
username: ${{ github.actor }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Docker meta
101+
id: meta
102+
uses: docker/metadata-action@v5
103+
with:
104+
images: ghcr.io/${{ github.repository }}
105+
tags: |
106+
type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}
107+
108+
- name: Push the multi-platform image
109+
run: |
110+
docker buildx imagetools create \
111+
--tag "$DOCKER_METADATA_OUTPUT_TAGS" \
112+
"$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64"
113+
114+
test:
115+
runs-on: ubuntu-24.04
116+
needs:
117+
- merge
118+
env:
119+
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
120+
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
121+
steps:
122+
- name: Checkout code
123+
uses: actions/checkout@v4
124+
125+
- name: Set up Docker Compose
126+
uses: docker/setup-compose-action@v1
127+
128+
- name: Login to GitHub Container Registry
129+
uses: docker/login-action@v3
130+
with:
131+
registry: ghcr.io
132+
username: ${{ github.actor }}
133+
password: ${{ secrets.GITHUB_TOKEN }}
134+
135+
- name: Start the stack
136+
run: |
137+
docker compose up --detach --wait
138+
139+
- name: Run the test script
140+
run: |
141+
docker compose exec app run-tests
142+
143+
push:
144+
runs-on: ubuntu-24.04
145+
needs:
146+
- merge
147+
- test
148+
env:
149+
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v4
153+
154+
- name: Login to GitHub Container Registry
155+
uses: docker/login-action@v3
156+
with:
157+
registry: ghcr.io
158+
username: ${{ github.actor }}
159+
password: ${{ secrets.GITHUB_TOKEN }}
160+
161+
- name: Produce permanent image tags
162+
id: branch-meta
163+
uses: docker/metadata-action@v5
164+
with:
165+
images: ghcr.io/${{ github.repository }}
166+
tags: |
167+
type=sha
168+
type=ref,event=branch
169+
type=raw,value=latest,enable={{is_default_branch}}
170+
171+
- name: Retag and push the image
172+
run: |
173+
docker pull "$DOCKER_APP_IMAGE"
174+
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE"
175+
docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)"

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Push Release Tags
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
DOCKER_METADATA_SET_OUTPUT_ENV: 'true'
12+
13+
jobs:
14+
retag:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Determine the sha-based image tag to retag
34+
id: get-base-image
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: type=sha
39+
40+
- name: Verify that the image was previously built
41+
env:
42+
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
43+
run: |
44+
docker pull "$BASE_IMAGE"
45+
46+
- name: Produce release tags
47+
id: tag-meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ghcr.io/${{ github.repository }}
51+
flavor: latest=false
52+
tags: |
53+
type=ref,event=tag
54+
type=semver,pattern={{major}}
55+
type=semver,pattern={{major}}.{{minor}}
56+
type=semver,pattern={{version}}
57+
58+
- name: Retag the pulled image
59+
env:
60+
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
61+
run: |
62+
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$BASE_IMAGE"
63+
docker push --all-tags "$(echo "$BASE_IMAGE" | cut -f1 -d:)"

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM tomcat:9-jre11-temurin-focal AS base
2+
3+
ARG GEOSERVER_VERSION="2.25.3"
4+
ENV GEOSERVER_VERSION=$GEOSERVER_VERSION
5+
ENV GEOSERVER_URL="https://sourceforge.net/projects/geoserver/files/GeoServer/${GEOSERVER_VERSION}/geoserver-${GEOSERVER_VERSION}-war.zip"
6+
ENV GEOSERVER_LIB_DIR="/usr/local/tomcat/webapps/geoserver/WEB-INF/lib"
7+
ENV GDAL_PLUGIN_URL="https://sourceforge.net/projects/geoserver/files/GeoServer/${GEOSERVER_VERSION}/extensions/geoserver-${GEOSERVER_VERSION}-gdal-plugin.zip"
8+
ENV CAS_PLUGIN_URL="https://sourceforge.net/projects/geoserver/files/GeoServer/${GEOSERVER_VERSION}/extensions/geoserver-${GEOSERVER_VERSION}-cas-plugin.zip"
9+
10+
RUN apt update && \
11+
apt -y --no-install-recommends install \
12+
gdal-bin \
13+
libgdal-dev \
14+
libgdal-java \
15+
libsqlite3-dev \
16+
sqlite3 \
17+
swig \
18+
unzip \
19+
wget && \
20+
apt clean && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
FROM base AS download-geoserver
24+
RUN wget -qO /tmp/geoserver-war.zip "${GEOSERVER_URL}" && \
25+
unzip /tmp/geoserver-war.zip -d /tmp/geoserver-war && \
26+
unzip /tmp/geoserver-war/geoserver.war -d /usr/local/tomcat/webapps/geoserver && \
27+
rm -rf /tmp/geoserver*
28+
29+
FROM base AS download-gdal-plugin
30+
RUN wget -qO /tmp/gdal-plugin.zip $GDAL_PLUGIN_URL && \
31+
unzip -o -d /tmp/gdal-plugin /tmp/gdal-plugin.zip && \
32+
rm -f /tmp/gdal-plugin.zip
33+
34+
FROM base AS download-cas-plugin
35+
RUN wget -qO /tmp/cas-plugin.zip $CAS_PLUGIN_URL && \
36+
unzip -o -d /tmp/cas-plugin /tmp/cas-plugin.zip && \
37+
rm -f /tmp/cas-plugin.zip
38+
39+
FROM base AS final
40+
COPY --from=download-geoserver /usr/local/tomcat/webapps/geoserver /usr/local/tomcat/webapps/geoserver
41+
COPY --from=download-cas-plugin /tmp/cas-plugin/*.jar $GEOSERVER_LIB_DIR/
42+
COPY --from=download-gdal-plugin /tmp/gdal-plugin/*.jar $GEOSERVER_LIB_DIR/
43+
44+
# Downgrade the gdal jar so it matches the gdal version installed on the system
45+
RUN rm -f $GEOSERVER_LIB_DIR/gdal-3.2.0.jar && \
46+
cp /usr/share/java/gdal.jar $GEOSERVER_LIB_DIR/gdal-3.0.4.jar
47+
48+
# Ensure libgdalalljni.so is in the load path. If this isn't found, GeoServer will log and warn
49+
# about that on startup.
50+
ENV LD_LIBRARY_PATH="/usr/lib/jni:$LD_LIBRARY_PATH"
51+
ENV GDAL_DATA="/usr/share/gdal"
52+
53+
# Redirect the root path to /geoserver/web
54+
# Inspired by https://github.com/geoserver/docker/blob/master/startup.sh
55+
RUN mkdir -p $CATALINA_HOME/webapps/ROOT
56+
COPY files/index.jsp $CATALINA_HOME/webapps/ROOT/
57+
COPY bin/run-tests /usr/local/bin/

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# GeoServer Docker Image
2+
3+
A Tomcat-based Docker image that installs and runs [GeoServer](https://geoserver.org/) with its CAS and GDAL plugins.
4+
5+
## Building the image
6+
7+
To build the default image:
8+
9+
```sh
10+
docker compose build
11+
```
12+
13+
You can also optionally set `GEOSERVER_VERSION` to the specific version of GeoServer you want built. The CAS and GDAL plugins are fetched relative to that version. Note that this is a Dockerfile build argument; it's just passed thru via the environment:
14+
15+
```sh
16+
GEOSERVER_VERSION=2.27.3 docker compose build
17+
```
18+
19+
## Running / testing
20+
21+
The following starts the app on `localhost:8080`. The test script just verifies that the default GeoServer login page is present.
22+
23+
```sh
24+
docker compose up --wait
25+
docker compose exec app run-tests
26+
```

bin/run-tests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh -e
2+
3+
curl -sqL --cookie-jar /tmp/cookies localhost:8080/geoserver/web/?0 | tac | grep -q 'GeoServer: Welcome'

docker-compose.ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
app:
3+
build: !reset
4+
image: ${DOCKER_APP_IMAGE}

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
app:
3+
build:
4+
args:
5+
- GEOSERVER_VERSION=${GEOSERVER_VERSION}
6+
context: .
7+
image: ucblib/geoserver:${DOCKER_TAG:-development}
8+
ports:
9+
- 8080:8080

files/index.jsp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%
2+
final String redirectURL = "/geoserver/web/";
3+
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
4+
response.setHeader("Location", redirectURL);
5+
%>

0 commit comments

Comments
 (0)