Skip to content

Commit

Permalink
Merge pull request #1 from ahennr/merge-master
Browse files Browse the repository at this point in the history
merge current master
  • Loading branch information
ahennr authored Jul 11, 2024
2 parents a019d67 + f22cb29 commit 541f971
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 28 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
postgis/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.iml
*.idea

postgis/
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM tomcat:9.0.85-jdk11-temurin-jammy
FROM tomcat:9.0.90-jdk11-temurin-jammy
LABEL vendor="osgeo.org"

# Build arguments
Expand Down Expand Up @@ -61,7 +61,7 @@ WORKDIR /tmp
RUN set -eux \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends openssl unzip curl gettext \
&& apt-get install -y --no-install-recommends openssl unzip curl locales gettext \
&& apt-get clean \
&& rm -rf /var/cache/apt/* \
&& rm -rf /var/lib/apt/lists/* \
Expand Down Expand Up @@ -112,11 +112,12 @@ RUN apt purge -y \

# GeoServer user => restrict access to $CATALINA_HOME and GeoServer directories
# See also CIS Docker benchmark and docker best practices
RUN chmod +x /opt/*.sh

WORKDIR /opt
RUN chmod +x /opt/*.sh && sed -i 's/\r$//' /opt/startup.sh

ENTRYPOINT ["bash", "/opt/startup.sh"]

ENTRYPOINT ["/opt/startup.sh"]
WORKDIR /opt

EXPOSE 8080

Expand Down
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ This Dockerfile can be used to create images for all geoserver versions since 2.
* JRE11 (eclipse temurin)
* Ubuntu Jammy (22.04 LTS)
* GeoServer installation is configurable and supports
* dynamic installation of extensions
* custom fonts (e.g. for SLD styling)
* Dynamic installation of extensions
* Custom fonts (e.g. for SLD styling)
* CORS
* additional libraries
* Additional libraries
* PostgreSQL JNDI
* HTTPS

This README.md file covers use of official docker image, additional [build](BUILD.md) and [release](RELEASE.md) instructions are available.

Expand All @@ -19,20 +21,20 @@ This README.md file covers use of official docker image, additional [build](BUIL
To pull an official image use ``docker.osgeo.org/geoserver:{{VERSION}}``, e.g.:

```shell
docker pull docker.osgeo.org/geoserver:2.24.2
docker pull docker.osgeo.org/geoserver:2.25.2
```
All the images can be found at: [https://repo.osgeo.org](https://repo.osgeo.org/#browse/browse:geoserver-docker:v2/geoserver/tags) and the latest stable and maintenance version numbers can be obtained from [https://geoserver.org/download/](https://geoserver.org/download/)

Afterwards you can run the pulled image locally with:

```shell
docker run -it -p 80:8080 docker.osgeo.org/geoserver:2.24.2
docker run -it -p 80:8080 docker.osgeo.org/geoserver:2.25.2
```

Or if you want to start the container daemonized, use e.g.:

```shell
docker run -d -p 80:8080 docker.osgeo.org/geoserver:2.24.2
docker run -d -p 80:8080 docker.osgeo.org/geoserver:2.25.2
```

Check <http://localhost/geoserver> to see the geoserver page,
Expand All @@ -49,7 +51,7 @@ To use an external folder as your geoserver data directory.
```shell
docker run -it -p 80:8080 \
--mount src="/absolute/path/on/host",target=/opt/geoserver_data/,type=bind \
docker.osgeo.org/geoserver:2.24.2
docker.osgeo.org/geoserver:2.25.2
```

An empty data directory will be populated on first use. You can easily update GeoServer while
Expand All @@ -64,7 +66,7 @@ The environment variable `SKIP_DEMO_DATA` can be set to `true` to create an empt
```shell
docker run -it -p 80:8080 \
--env SKIP_DEMO_DATA=true \
docker.osgeo.org/geoserver:2.24.2
docker.osgeo.org/geoserver:2.25.2
```

## How to issue a redirect from the root ("/") to GeoServer web interface ("/geoserver/web")?
Expand All @@ -85,16 +87,16 @@ The ``startup.sh`` script allows some customization on startup:
* ``CORS_ALLOW_CREDENTIALS`` (default ``false``) **Setting this to ``true`` will only have the desired effect if ``CORS_ALLOWED_ORIGINS`` defines explicit origins (not ``*``)**
* ``PROXY_BASE_URL`` to the base URL of the GeoServer web app if GeoServer is behind a proxy. Example: ``https://example.com/geoserver``.

The CORS variables customize tomcat's `web.xml` file. If you need more customization,
you can provide your own customized `web.xml` file to tomcat by mounting it into the container
The CORS variables customize tomcat's `web.xml` file. If you need more customization,
you can provide your own customized `web.xml` file to tomcat by mounting it into the container
at `/opt/config_overrides/web.xml`.

Example installing wps and ysld extensions:

```shell
docker run -it -p 80:8080 \
--env INSTALL_EXTENSIONS=true --env STABLE_EXTENSIONS="wps,ysld" \
docker.osgeo.org/geoserver:2.24.2
docker.osgeo.org/geoserver:2.25.2
```

The list of extensions (taken from SourceForge download page):
Expand All @@ -119,7 +121,7 @@ If you want to add geoserver extensions/libs, place the respective jar files in
```shell
docker run -it -p 80:8080 \
--mount src="/dir/with/libs/on/host",target=/opt/additional_libs,type=bind \
docker.osgeo.org/geoserver:2.24.2
docker.osgeo.org/geoserver:2.25.2
```

## How to add additional fonts to the docker image (e.g. for SLD styling)?
Expand All @@ -129,7 +131,7 @@ If you want to add custom fonts (the base image only contains 26 fonts) by using
```shell
docker run -it -p 80:8080 \
--mount src="/dir/with/fonts/on/host",target=/opt/additional_fonts,type=bind \
docker.osgeo.org/geoserver:2.24.2
docker.osgeo.org/geoserver:2.25.2
```

**Note:** Do not change the target value!
Expand Down Expand Up @@ -164,9 +166,19 @@ Example:
```shell
docker run -it -p 80:8080 \
--mount src="/path/to/my/server.xml",target=/opt/config_overrides/server.xml,type=bind \
docker.osgeo.org/geoserver:2.24.1
docker.osgeo.org/geoserver:2.25.1
```

## How to enable HTTPS?

To enable HTTPS, mount a JKS file to the container (ex. `/opt/keystore.jks`) and provide the following environment
variables:

* ``HTTPS_ENABLED`` to `true`
* ``HTTPS_KEYSTORE_FILE`` (defaults to `/opt/keystore.jks`)
* ``HTTPS_KEYSTORE_PASSWORD`` (defaults to `changeit`)
* ``HTTPS_KEY_ALIAS`` (defaults to `server`)

## How to use the docker-compose demo?

The ``docker-compose-demo.yml`` to build with your own data directory and extensions.
Expand Down Expand Up @@ -205,6 +217,8 @@ Following is the list of the all the environment variables that can be passed do
| SKIP_DEMO_DATA | Indicates whether to skip the installation of demo data provided by GeoServer | `false` |
| ROOT_WEBAPP_REDIRECT | Indicates whether to issue a permanent redirect to the web interface | `false` |
| HEALTHCHECK_URL | URL to the resource / endpoint used for `docker` health checks | `http://localhost:8080/geoserver/web/wicket/resource/org.geoserver.web.GeoServerBasePage/img/logo.png` |
| GEOSERVER_ADMIN_USER | Admin username | |
| GEOSERVER_ADMIN_PASSWORD | Admin password | |

The following values cannot really be safely changed (as they are used to download extensions and community modules as the docker image first starts up).
| VAR NAME | DESCRIPTION | SAMPLE VALUE |
Expand Down
12 changes: 6 additions & 6 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OSGeo maintains geoserver-docker.osgeo.org repository for publishing. The result
Build locally:

```shell
docker build -t geoserver-docker.osgeo.org/geoserver:2.24.2 .
docker build -t geoserver-docker.osgeo.org/geoserver:2.25.2 .
```

Login using with osgeo user id:
Expand All @@ -19,7 +19,7 @@ docker login geoserver-docker.osgeo.org
Push to osgeo repository:

```shell
docker push geoserver-docker.osgeo.org/geoserver:2.24.2
docker push geoserver-docker.osgeo.org/geoserver:2.25.2
```

## How to automate release?
Expand All @@ -34,10 +34,10 @@ The third, optional, is used to supply the jenkins build number - triggering a n

Examples:

`./release.sh build 2.24.2`
`./release.sh build 2.25.2`

`./release.sh publish 2.24.2`
`./release.sh publish 2.25.2`

`./release.sh buildandpublish 2.24.2`
`./release.sh buildandpublish 2.25.2`

`./release.sh buildandpublish 2.24-SNAPSHOT 1234`
`./release.sh buildandpublish 2.25-SNAPSHOT 1234`
2 changes: 1 addition & 1 deletion build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function usage() {
echo "$0 <mode> <version> [<build>]"
echo ""
echo " mode : The mode. Choose one of 'build', 'publish' or 'buildandpublish'"
echo " version : The released version to build an docker image for (eg: 2.24.2, ${MAIN}-SNAPSHOT, ${MAIN}-RC)"
echo " version : The released version to build an docker image for (eg: 2.25.2, ${MAIN}-SNAPSHOT, ${MAIN}-RC)"
echo " build : Build number (optional)"
}

Expand Down
181 changes: 181 additions & 0 deletions config/server-https.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!-- APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
/>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true"
maxParameterCount="1000"
>
<SSLHostConfig>
<Certificate certificateKeystoreFile="${HTTPS_KEYSTORE_FILE}"
certificateKeystorePassword="${HTTPS_KEYSTORE_PASSWORD}"
certificateKeyAlias="${HTTPS_KEY_ALIAS}"
type="RSA" />
</SSLHostConfig>
</Connector>
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true"
maxParameterCount="1000"
>
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443"
maxParameterCount="1000"
/>
-->

<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
</Engine>
</Service>
</Server>
2 changes: 1 addition & 1 deletion docker-compose-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
build:
context: .
args:
- GEOSERVER_VERSION=2.24.2
- GEOSERVER_VERSION=2.25.2
- CORS_ENABLED=true
- CORS_ALLOWED_METHODS=GET,POST,PUT,HEAD,OPTIONS
ports:
Expand Down
Loading

0 comments on commit 541f971

Please sign in to comment.