Giter Site home page Giter Site logo

docker-geoserver's Introduction

docker-geoserver

How to run it

Pull the image from Docker Hub

docker pull geosolutionsit/geoserver

And run it

docker run --name gs -p 8080:8080 geosolutionsit/geoserver

Or for data persistence starting with default geoserver datadir (in this example GEOSERVER_DATA_DIR is pointing to /var/geoserver/datadir):

docker run --rm --name gs -p 8080:8080 geosolutionsit/geoserver

Save datadir locally to have a starting datadir:

docker cp gs:/var/geoserver/datadir ./datadir
docker stop gs

start GeoServer with data persistence on saved datadir:

docker run -v datadir:/var/geoserver/datadir --name gs -p 8080:8080 geosolutionsit/geoserver

start GeoServer with data persistence on saved datadir and change admin password:

docker run -e ADMIN_PASSWORD=securepassword -v datadir:/var/geoserver/datadir --name gs -p 8080:8080 geosolutionsit/geoserver

Open your browser and point it to http://localhost:8080/geoserver . GeoServer web interface will show up, you can now log in with user admin and password geoserver.

There are some environment variables you can use at run time:

  • CATALINA_OPTS to customize CATALINA_OPTS for the container
  • EXTRA_GEOSERVER_OPTS to append to CATALINA_OPTS
  • GEOSERVER_LOG_DIR to customize log placement
  • GEOSERVER_DATA_DIR to put your GeoServer datadir elsewhere
  • GEOWEBCACHE_CONFIG_DIR to put your GeoServer cache configuration elsewhere
  • GEOWEBCACHE_CACHE_DIR to put your GeoServer cache elsewhere
  • NETCDF_DATA_DIR to put your GeoServer NETCDF data dir elsewhere
  • GRIB_CACHE_DIR to put your GeoServer GRIB cache dir elsewhere

Each of these variables can be associated to an external volume to persist data for example in a docker compose configuration. More information about this in the section below.

Example of how to build a docker image with just geoserver war and then add plugins at runtime.

docker build -t geoserver:test-2.19.1 \
--build-arg GIT_HASH=`git show -s --format=%H` \
--build-arg GEOSERVER_WEBAPP_SRC=https://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/geoserver-2.19.1-war.zip/download  .

docker run \
--env PLUGIN_DYNAMIC_URLS="http://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/extensions/geoserver-2.19.1-control-flow-plugin.zip \
http://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/extensions/geoserver-2.19.1-libjpeg-turbo-plugin.zip" \
--rm --name gs -p 8080:8080 geoserver:test-2.19.1

Using GeoServer with docker-compose

Docker Compose is a tool that helps us easily handle multiple containers at once.

Install instructions: Docker Docs

In order to use Compose we need first to set correctly the "docker-compose.yml" file of the Docker-GeoServer.

Externalize the data directory of the GeoServer container

In order to persist and externalize access to the data of the geoserver container we need to set the values of the environment variables (named in the previous section) on the container and then associated this to the external volumes we going to create.

To achieve this, first we gonna create a .env file (in the same folder of the docker-compose.yml file) to define in an optimal way (easy to modify later) the environment variables values for the geoserver container:

.env file content:

GEOSERVER_LOG_DIR=/var/geoserver/logs
GEOSERVER_DATA_DIR=/var/geoserver/datadir
GEOWEBCACHE_CONFIG_DIR=/var/geoserver/datadir/gwc
GEOWEBCACHE_CACHE_DIR=/var/geoserver/gwc_cache_dir
NETCDF_DATA_DIR=/var/geoserver/netcdf_data_dir
GRIB_CACHE_DIR=/var/geoserver/grib_cache_dir

More details on the definition of the .env file: Docker - The Compose Specification

Then we are going to modify the docker-compose configuration file to set environment variables in the geoserver container with the “environment” key:

...
geoserver:
    build:
      context: .
      dockerfile: ./Dockerfile
    ...
    environment:
      - GEOSERVER_LOG_DIR=${GEOSERVER_LOG_DIR}
      - GEOSERVER_DATA_DIR=${GEOSERVER_DATA_DIR}
      - GEOWEBCACHE_CONFIG_DIR=${GEOWEBCACHE_CONFIG_DIR}
      - GEOWEBCACHE_CACHE_DIR=${GEOWEBCACHE_CACHE_DIR}
      - NETCDF_DATA_DIR=${NETCDF_DATA_DIR}
      - GRIB_CACHE_DIR=${GRIB_CACHE_DIR}
...

To be sure that the environment variables are not pass empty, you can set a default value.

Example:

...
geoserver:
...
    environment:
      - GEOSERVER_LOG_DIR=${GEOSERVER_LOG_DIR:-/var/geoserver/logs}
...

If GEOSERVER_LOG_DIR variable is not set in the .env file, is going to take his default value.

Next we are going to define the external volumes, modifying again the docker-compose configuration file.

services:
...
  geoserver:
    ...
    volumes:
      - logs:${GEOSERVER_LOG_DIR}
      - datadir:${GEOSERVER_DATA_DIR}
      - gwc_config:${GEOWEBCACHE_CONFIG_DIR}
      - gwc:${GEOWEBCACHE_CACHE_DIR}
      - netcfd:${NETCDF_DATA_DIR}
      - grib_cache:${GRIB_CACHE_DIR}
  ...
volumes:
  pg_data:
  logs:
  datadir:
  gwc_config:
  gwc:
  netcfd:
  grib_cache:

Both configurations together (environment variables and external volumes) are going to show like this in the docker-compose configuration file:

services:
...
  geoserver:
    build:
      context: .
      dockerfile: ./Dockerfile
    ...
    environment:
      - GEOSERVER_LOG_DIR=${GEOSERVER_LOG_DIR}
      - GEOSERVER_DATA_DIR=${GEOSERVER_DATA_DIR}
      - GEOWEBCACHE_CONFIG_DIR=${GEOWEBCACHE_CONFIG_DIR}
      - GEOWEBCACHE_CACHE_DIR=${GEOWEBCACHE_CACHE_DIR}
      - NETCDF_DATA_DIR=${NETCDF_DATA_DIR}
      - GRIB_CACHE_DIR=${GRIB_CACHE_DIR}
    volumes:
      - logs:${GEOSERVER_LOG_DIR}
      - datadir:${GEOSERVER_DATA_DIR}
      - gwc_config:${GEOWEBCACHE_CONFIG_DIR}
      - gwc:${GEOWEBCACHE_CACHE_DIR}
      - netcfd:${NETCDF_DATA_DIR}
      - grib_cache:${GRIB_CACHE_DIR}
  ...
volumes:
  pg_data:
  logs:
  datadir:
  gwc_config:
  gwc:
  netcfd:
  grib_cache:

After this our geoserver container is ready and persisting his data.

For more details about volumes, check the documentation: Docker - Volume

Using an alternative war file to build GeoServer container of the stack

In the docker-compose.yml file, actually we are building the GeoServer container from a image on a URL.

...
geoserver:
    build:
      context: .
      dockerfile: ./Dockerfile
      args:
        GEOSERVER_WEBAPP_SRC: "https://build.geoserver.org/geoserver/main/geoserver-main-latest-war.zip"
    container_name: geoserver 
...

This is dynamic, you can use a local file in the host to build the container as and alternative if you need. In order to do this, we need to modify the docker-compose configuration file like this:

...
geoserver:
    build:
      context: .
      dockerfile: ./Dockerfile
      args:
        GEOSERVER_WEBAPP_SRC: "/host/directory/alternativegeoserver.war"
    container_name: geoserver 
...

This option allows you to use URLs and local files as well to build the GeoServer container in the option that suit you best.

For more details, check the ADD documentation: Docker - ADD

Using custom .war file at runtime in Docker Compose

  • Example configuration for the geoserver service:
...
geoserver:
  image: geosolutionsit/geoserver:2.23.0 ## Initially, include an image to avoid Docker complaints.
  volumes:
    - /path/custom-war:/usr/local/tomcat/webapps/geoserver ## Define a volume pointing to your custom .war, ensuring it's unzipped.
  environment:
    - EXTRA_GEOSERVER_OPTS="-DGEOSERVER_CSRF_WHITELIST=example.org -DENABLE_JSONP=true"
  container_name: geoserver
  depends_on:
    postgres:
      condition: service_healthy
  ports:
    - 8080
  networks:
    - geoserver-network

...

Adjusting Permissions for the bind mounts.

-Identify User ID: Determine the user ID running Geoserver inside the container. Use docker exec to access the container and run the id command.

-Adjust Permissions: On the host system, use chown to set the owner of the directory containing Geoserver files to match the user ID. Then, use chmod to set appropriate permissions.

-Assuming user ID is 1000 and directory is /path/custom-war

sudo chown -R 1000:1000 /path/custom-war
sudo chmod -R 755 /path/custom-war

Accessing GeoServer postgresql server from outside the container

Containers communicate between themselves in networks created, implicitly or through configuration, by docker compose. To reach a container from the host, the ports must be exposed declaratively through the "ports" keyword, which also allows us to choose if we want exposing the port differently in the host.

ports:
- "hostport:containerport" #host:container SHOULD always be specified as a (quoted) string, to avoid conflicts with yaml base-60 float.

The Host port and the Container Port can be equal or no, this option allows us to run different containers exposing the same ports without collisions.

GeoServer docker-compose.yml:

services:
  postgres:
    image: postgis/postgis
    container_name: postgres
    ...
    ports:
      - 5432
    ...

  geoserver:
    ...
    container_name: geoserver
    ...
    ports:
      - 8080
    ...

  proxy:
    image: nginx
    container_name: proxy
    ...
    ports:
    - "80:80"
    ...

In this example the only port visible in the host will be port 80 of the proxy container.

In order to access the postgresql server from outside the container, we need to use the "port" option to expose a port.

services:
  postgres:
    image: postgis/postgis
    container_name: postgres
    ...
    ports:
      - "5432:5432"
    ...

To test the expose, we can use "curl" command in the host:

curl -v localhost:5432

*   Trying 127.0.0.1:5432...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5432 (#0)
> GET / HTTP/1.1
> Host: localhost:5432
> User-Agent: curl/7.68.0
> Accept: */*

More details on expose containers ports: Docker - The Compose Specification

Starting the containers

When we have everything configured with the docker-compose.yml file, to start the containers for the first time we gonna use this command (located in the directory when the yml file is):

docker-compose up

This is gonna create and start the containers, the networks, and the volumes defined in the docker-compose.yml file. This is the command you need to use every time after a change on the docker-compose.yml file in order to apply the modifications.

After the first time, we can simply use this command to start the containers:

docker-compose start

Console output:

Starting postgres ... done
Starting geoserver ... done
Starting proxy ... done
...
(Continued with the proxy logs)

To stopping all the containers, this is the command:

docker-compose stop

Console output:

Stopping proxy ... done
Stopping geoserver ... done
Stopping postgres  ... done

If you want to reset the status of the containers, we need to run this command, which will destroy everything with only the exception of external volumes:

docker-compose down

How to build the Docker image with your own geoserver.war file

Make sure you have your war file at ./geoserver.war

 docker build --build-arg GEOSERVER_WEBAPP_SRC="./geoserver.war" -t geoserver:test .

There are build arguments to customize the image:

  • PLUG_IN_URLS space-separated list of additional plugins for geoserver (see examples), this works both for extensions and community plugins.
  • GEOSERVER_DATA_DIR_SRC add a customized datadir to the final image. This can be a local zip or directory or remote URL (see ADD documentation)
  • GEOSERVER_WEBAPP_SRC to add your own custom web app to the final image. This can be a local zip or directory or remote URL (see ADD instruction Doc). If you want to build or package your own web app you can customize the "mother" stage of Dockerfile accordingly, if you want to download directly GeoServer you may need to add /download at the end of download url which you can copy/paste from GeoServer official downloads page, see last example below

Examples about using Docker image

# Example of how to build a single customized war of geoserver or simply any vanilla one
docker build -t geoserver:test . --build-arg GEOSERVER_WEBAPP_SRC="./resources/geoserver/geoserver.war"

# Same kind of build as above but burning custom datadir inside GeoServer Docker image

docker build -t geoserver:test . --build-arg GEOSERVER_WEBAPP_SRC="./resources/geoserver/geoserver.war" --build-arg GEOSERVER_DATA_DIR_SRC="./resources/geoserver-datadir/"

# Example on how to download and build a geoserver version with stable plugins controlflow and libjpegturbo plugins burned in the image
docker build -t geoserver:luca-test-2.19.1 --build-arg GEOSERVER_WEBAPP_SRC="https://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/geoserver-2.19.1-war.zip/download" --build-arg PLUG_IN_URLS="http://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/extensions/geoserver-2.19.1-control-flow-plugin.zip http://sourceforge.net/projects/geoserver/files/GeoServer/2.19.1/extensions/geoserver-2.19.1-libjpeg-turbo-plugin.zip" .

GeoServer rest reload

While the container is running you can reload geoserver with:

docker exec -it <your-container-name> bash /usr/local/bin/geoserver-rest-reload.sh

Test plugins on running container

docker exec -it <your-container-name> bash -c 'geoserver-plugin-download.sh $CATALINA_BASE/webapps/$APP_LOCATION/WEB-INF/lib <space separated list of plugin urls>'

Docker Hub build process and related helper scripts

Scripts provided that are for docker hub are under hooks directory.

Basically the hooks/build script takes these environment variables with current version numbers offered for geoserver:

export MAINT_VERSION="2.17.3 2.17.2 2.17.1"
export MIDDLE_STABLE="18"
export NIGHTLY_MAINT_VERSION="2.17.x"
export NIGHTLY_MASTER_VERSION="master foobar"
export NIGHTLY_STABLE_VERSION="2.18.x"
export STABLE_VERSION="2.18.1 2.18.0"

Notes:

Phantom version foobar is supposed to always fail as a test and always tried to be built. "MIDDLE_STABLE" has just a function for the scripts logic, increase it with latest minor version number for stable.

To test locally build hook you can use the test_hooks.sh script provided.

How to use custom_build.sh script

the script can be run with no parameters to show the needed parameters:

./custom_build.sh
Usage: ./custom_build.sh [docker image tag] [geoserver version] [geoserver master version] [datadir| nodatadir] [pull|no pull];

[docker image tag] :          the tag to be used for the docker iamge
[geoserver version] :         the release version of geoserver to be used; you can set it to master if you want the last release
[geoserver master version] :  if you use the master version for geoserver you need to set it to the numerical value for the next release;
                              if you use a released version you need to put it to the release number
[datadir| nodatadir]:         if this parameter is equal to nodatadir the datadir is not burned in the docker images
[pull|no pull]:               docker build use always a remote image or a local image

This script is meant to be used by automated build, variety of tests with highly customized versions of geoserver.

Example

./custom_build.sh my-docker-tag 2.18.x 2.18.x nodatadir no_pull

GIT HASH INFORMATION

This argument provides git hash information from inside of container. In order to get git hash information inside of container add this argument to the build line. As requirement git command should be installed.

--build-arg GIT_HASH=git show -s --format=%H

Below command shows git hash information.

docker exec -it bash -c 'echo $GIT_HASH'

docker-geoserver's People

Contributors

agpenton avatar boukandouramhamed avatar camuffo avatar chrimohr avatar david7378 avatar dawitanelay avatar drumbsd avatar dydoc avatar fernandor777 avatar gnafu avatar lpasquali avatar morl99 avatar pablobaronetti avatar randomorder avatar razor54 avatar sycured avatar zsarkad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-geoserver's Issues

Fix Geoserver stable Docker builds

They're not built anymore since the build server upgrade....

This is the opportunity to define a new tagging system for stable releases: we will tag them with their own version (e.g. 2.15.3) and as "stable". This way we can always refer to the latest stable release if needed.

Dependencies should be updated

We see a lot of CVEs in the image, which could be removed by updating to more current versions:

CVE-2021-23463	    CRITICAL	1.1.119	        2.0.202                     com.h2database:h2	
CVE-2021-42392	    CRITICAL	1.1.119	        2.0.206                     com.h2database:h2	
CVE-2022-23221	    CRITICAL	1.1.119	        2.1.210                     com.h2database:h2	
CVE-2022-22978	    CRITICAL	5.1.13.RELEASE	5.5.7, 5.6.4.               org.springframework.security:spring-security-core	
CVE-2016-1000027    CRITICAL	5.2.22.RELEASE	6.0.0                       org.springframework:spring-web	
CVE-2022-45868	    HIGH    	1.1.119	                                    com.h2database:h2	
CVE-2023-24998	    HIGH    	1.4.            1.5                         commons-fileupload:commons-fileupload	
CVE-2022-45143	    HIGH    	9.0.65	        8.5.84, 9.0.69, 10.1.2      org.apache.tomcat:tomcat-catalina	
CVE-2022-42252	    HIGH    	9.0.65	        8.5.83, 9.0.68,
                                                10.0.27, 10.1.1             org.apache.tomcat:tomcat-coyote	
CVE-2021-22112	    HIGH    	5.1.13.RELEASE	5.2.9.RELEASE,
                                                5.3.8.RELEASE, 5.4.4        org.springframework.security:spring-security-core	
CVE-2021-22112	    HIGH    	5.1.13.RELEASE	5.2.9, 5.2.9, 5.4.4, 5.4.4  org.springframework.security:spring-security-web	
CVE-2022-34169	    HIGH    	2.7.2	                                    xalan:xalan	
CVE-2022-22976	    MEDIUM	5.1.13.RELEASE	5.5.7, 5.6.4                org.springframework.security:spring-security-core	
GHSA-h376-j262-vhq6 UNKNOWN     1.1.119	        2.0.206                     com.h2database:h2

Issue downloading libjpegturbo source files

Docker image builds are currently failing dur to retrieval of external dependency

...
023-11-08T10:21:37Z #9 1933.9 --2023-11-08 10:21:37-- (try:15) https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz
2023-11-08T10:23:47Z #9 1933.9 Connecting to nav.dl.sourceforge.net (nav.dl.sourceforge.net)|5.154.224.27|:443... failed: Connection timed out.
2023-11-08T10:23:47Z #9 2063.1 Retrying.
2023-11-08T10:23:47Z #9 2063.1
2023-11-08T10:23:57Z #9 2073.1 --2023-11-08 10:23:57-- (try:16) https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz
2023-11-08T10:26:06Z #9 2073.1 Connecting to nav.dl.sourceforge.net (nav.dl.sourceforge.net)|5.154.224.27|:443... failed: Connection timed out.
2023-11-08T10:26:06Z #9 2202.4 Retrying.
2023-11-08T10:26:06Z #9 2202.4
2023-11-08T10:26:16Z #9 2212.4 --2023-11-08 10:26:16-- (try:17) https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz
2023-11-08T10:28:25Z #9 2212.4 Connecting to nav.dl.sourceforge.net (nav.dl.sourceforge.net)|5.154.224.27|:443... failed: Connection timed out.
2023-11-08T10:28:25Z #9 2341.7 Retrying.
2023-11-08T10:28:25Z #9 2341.7
2023-11-08T10:28:35Z #9 2351.7 --2023-11-08 10:28:35-- (try:18) https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz
2023-11-08T10:30:45Z #9 2351.7 Connecting to nav.dl.sourceforge.net (nav.dl.sourceforge.net)|5.154.224.27|:443... failed: Connection timed out.
2023-11-08T10:30:45Z #9 2480.9 Retrying.
2023-11-08T10:30:45Z #9 2480.9
2023-11-08T10:30:54Z #9 2490.9 --2023-11-08 10:30:54-- (try:19) https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz
2023-11-08T10:33:04Z #9 2490.9 Connecting to nav.dl.sourceforge.net (nav.dl.sourceforge.net)|5.154.224.27|:443... failed: Connection timed out.

Multi platform compatible docker image builds.

I noticed that the build of the docker image in the repository is just linux/amd64, and in my case that image is not useful, cause my system is on ARM architecture. So I got 2 errors:

  1. since the image is on amd64, I can't run that image.
  2. I've tried to build the image from the Dockerfile, and I got an error when apt try to install libjpeg-turbo-official.
    • This is part of the output of the error:
           #15 4.361 dpkg: error processing archive ./libjpeg-turbo-official_1.5.3_amd64.deb (--install):
           #15 4.361  package architecture (amd64) does not match system (arm64)
           #15 4.651 Errors were encountered while processing: 
           #15 4.652  ./libjpeg-turbo-official_1.5.3_amd64.deb
           ------
           error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c wget 
           https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.3/libjpeg-turbo-official_1.5.3_amd64.deb && dpkg -i ./libjpeg*.deb && apt-get -f install]: exit code: 1
      

Matching tags or releases on github and dockerhub

I am just diving in to running geoserver, and I am trying to understand which version of which services and extensions are included in your public docker builds.

Could it be a good idea to create matching releases here on github, with changelogs that indicate the versions that are included?

docker-compose up not working

Docker-compose version used
docker-compose version 1.29.2, build 5becea4c
Command used in the write directory
docker-compose up
ERROR:
The Compose file './docker-compose.yml' is invalid because: services.geoserver.depends_on contains an invalid type, it should be an array

set username & password by env variables

Sorry for the stupid question: But is there a way in your current docker images to set the username & the password with environment variables? Having this is a really nice feature for the using the geoserver in more complex docker setups & ci/cd pipelines. Many other images already support that (postgres, wildfly, minio, and many more).

Is there a way to do it maybe out-of-the-box with the current image? Say the geosolutionsit/geoserver:2.18.1?
If not do you plan to add it?

Or will it be necessary to have a custom entrypoint script that do this changes?

Say something like this:

GEOSERVER_ADMIN_HASH=$(java -classpath /usr/local/tomcat/webapps/geoserver/WEB-INF/lib/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptStringDigestCLI digest.sh algorithm=SHA-256 saltSizeBytes=16 iterations=100000 input="$GEOSERVER_PASSWORD" verbose=0 | tr -d '\n')

cat <<END_OF_XML > "${GS_DATA_DIR}/security/usergroup/default/users.xml"
<?xml version="1.0" encoding="UTF-8"?><userRegistry xmlns="http://www.geoserver.org/security/users" version="1.0">
<users>
<user enabled="true" name="$GEOSERVER_USERNAME" password="digest1:$GEOSERVER_PASSWORD_HASH" />
</users>
<groups/>
</userRegistry>
END_OF_XML

(Basically I found parts of that on the geonode docker entrypoint.sh : https://github.com/GeoNode/geonode/blob/master/scripts/spcgeonode/geoserver/docker-entrypoint.sh - however the geonode image has other drawbacks).

Run tomcat as non-root user

Current implementation of the docker image is running tomcat as root user
image

It'd be nice to be able to run the service as a non-root user from a security standpoint. This is a popular request among our customers

docker build failing due to missing postgresql-11 package

looks like the apache tomcat docker image maintainers have updated their base Debian distribution and the package is not available any longer.

image

PostgreSQL client is not used directly by geoserver so we can bump the version as needed

Geoserver login forms not sending to https

I have set up a geoserver within a K8S environment. As base, I use the official docker image. The server is reachable internally via https and will, when fully configured, be publicly accessible.

When I try to login to geoserver (lets say under the url 'https://geoserver.institute.com'), I see the default entry page, but i cannot login, because the login form points to 'http://geoserver.institute.com/geoserver/j_spring_security_check' (http, not https).

However, I can change the html content to send the request to https. Doing so enables me to successfully log in. Since this is quite a dirty hack, I would appreciate a solution.

Thank you in advance!

Improve documentation for docker-compose usage

We want to improve the documentation for the docker-compose usage with

  • a step by step documentation on how to start the stack with docker-compose
  • how to connect to postgresql
  • externalize the data directory
  • how to use an alternative war file

Geoerver not getting UP while deploying as StatefulSet in Kubernetes

I was trying to deploy geoserver as a StatefulSet in Kubernetes. When we mount the data directory geoserver is not getting up.

I was getting the error in the logs as waiting for the geoserver to be up and running.

I was able to deploy without mounting the directory and there is no persistance for the data in that case.

Could you please guide as in deploying as a StatefulSet

Windows `CR/LF` line endings in .sh files

The presence of Windows styles for carriage returns prevents the correct building of the geoserver-docker image. This type of line endings is incompatible with Docker and prevents the image building. To make line endings Linux styled (and Docker compatible) a run of the dos2unix must be done on all .sh files. Despite performing this operation some line endings, switch to Windows style (this verified on on Windows wsl Ubuntu) if the docker-compse.yaml file is run for the second time.

For example, the failing file (despite the dos2unix command run) is /usr/local/bin/docker-entrypoint.sh and this happens when building the postgres container, the error message is

postgres   | 2023-07-25 10:52:36.719 UTC [48] LOG:  database system is ready to accept connections
postgres   |  done
postgres   | server started
postgres   |
postgres   | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/01-init-user.sh
postgres   |
postgres   | /usr/bin/env: ‘bash\r’: No such file or directory
dependency failed to start: container postgres is unhealthy

Docker image gs-stable-2.24.x does not start due to missing GeoDBDialect

As the latest geosolutionsit/geoserver:2.24.2 does not yet contain #139, I tried geosolutionsit/geoserver:gs-stable-2.24.x.

The geoserver does no start, due to apparently installed geofence-plugin:

/usr/local/tomcat$ ls -l webapps/geoserver/WEB-INF/lib/ | grep geofence
-rw-r--r-- 1 tomcat tomcat    58624 Nov  9 14:27 geofence-model-internal-3.7.1.jar
-rw-r--r-- 1 tomcat tomcat    38243 Nov  9 14:27 geofence-persistence-3.7.1.jar
-rw-r--r-- 1 tomcat tomcat    41088 Nov  9 14:27 geofence-services-api-3.7.1.jar
-rw-r--r-- 1 tomcat tomcat    51285 Nov  9 14:27 geofence-services-impl-3.7.1.jar
-rw-r--r-- 1 tomcat tomcat 13984739 Apr 24 07:34 geoserver-2.24-SNAPSHOT-geofence-server-plugin.zip
-rw-r--r-- 1 tomcat tomcat   101531 Apr 24 07:34 gs-geofence-2.24-SNAPSHOT.jar
-rw-r--r-- 1 tomcat tomcat   167541 Apr 24 07:34 gs-geofence-server-2.24-SNAPSHOT.jar

The exception

29-Apr-2024 17:51:00.444 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.geoserver.platform.GeoServerContextLoaderListener]
	org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'geofenceEntityManagerFactory' defined in URL [jar:file:/usr/local/tomcat/webapps/geoserver/WEB-INF/lib/geofence-persistence-3.7.1.jar!/applicationContext-geofenceDatasource.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: geofence] Unable to build EntityManagerFactory
		at 
...
	Caused by: javax.persistence.PersistenceException: [PersistenceUnit: geofence] Unable to build EntityManagerFactory
		at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
		at org.springframework.orm.jpa.vendor.SpringHibernateEjbPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateEjbPersistenceProvider.java:51)
		at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
		at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
		... 54 more
	Caused by: org.hibernate.HibernateException: Dialect class not found: org.hibernatespatial.geodb.GeoDBDialect
		at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:159)
		at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
		at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
		at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
		at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
		at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
		at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
		... 59 more
	Caused by: java.lang.ClassNotFoundException: org.hibernatespatial.geodb.GeoDBDialect
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1412)
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1220)
		at java.base/java.lang.Class.forName0(Native Method)
		at java.base/java.lang.Class.forName(Class.java:315)
		at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
		at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
		... 65 more
29-Apr-2024 17:51:00.459 INFO [main] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext

suggests that org.hibernatespatial.geodb.GeoDBDialect is missing.

The installed hibernate jars are:

ls -l webapps/geoserver/WEB-INF/lib/ | grep hibernate
-rw-r--r-- 1 tomcat tomcat    71283 May  4  2020 hibernate-commons-annotations-3.2.0.Final.jar
-rw-r--r-- 1 tomcat tomcat  3119700 May  4  2020 hibernate-core-3.6.9.Final.jar
-rw-r--r-- 1 tomcat tomcat    11280 May  4  2020 hibernate-ehcache-3.6.9.Final.jar
-rw-r--r-- 1 tomcat tomcat   426314 May  4  2020 hibernate-entitymanager-3.6.9.Final.jar
-rw-r--r-- 1 tomcat tomcat   102661 May  4  2020 hibernate-jpa-2.0-api-1.0.1.Final.jar
-rw-r--r-- 1 tomcat tomcat    92968 Feb  8  2021 hibernate-spatial-1.1.3.2.jar
-rw-r--r-- 1 root   root      15969 Feb  8  2021 hibernate-spatial-postgis-1.1.3.2.jar
-rw-r--r-- 1 tomcat tomcat    15520 May  4  2020 search-hibernate-1.1.0.jar
-rw-r--r-- 1 tomcat tomcat     3261 May  4  2020 search-jpa-hibernate-1.1.0.jar

As this repo has the geofence plugins commented out, I wonder what the source of the gs-stable-2.24.x image is(?)

docker image for 2.18.5

latest stable, 2.18.5 is missing from docker hub. I've tried to add the version number to the build config and trigger a build
image

but I can't find the new image on docker hub
image

Error building with custom_build.sh script

I tried to build the docker image with the custom_build script but got two problems:

  • Since I'm trying to build the docker image in ARM architecture, I can't use the regular docker build command, so I needed to change the script to docker buildx build.
  • and the second problem is that the build didn't pass after downloading the GeoServer.war file. The error that I got there was this one:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 89.5M  100 89.5M    0     0  4711k      0  0:00:19  0:00:19 --:--:-- 4691k
* geoserver.war.zip artefact dowloaded *
./custom_build.sh: line 58: -2: substring expression < 0

catalina_wrapper.sh is missing in the Dockerfile.

Running the Geoserver docker image with the variable GEOSERVER_APP_NAME="backend" and checking that the folder inside the container, I noticed that the directory remains with the default name GeoServer, so the URL doesn't work.
investigating the cause, I saw that the catalina_wrapper.sh is missing in the Dockerfile.

arm64 docker image?

Hello,

is it possible to provide a multi-architecture docker image. I'm looking for a docker image for arm64 architecture of geoserver.

Best regards,
Martin

Feature Request: Support EXTRA_GEOSERVER_OPTS

In case someone wants to start the docker container with additional GEOSERVER_OPTS, all the default opts need to be redefined.

A new ENV variable EXTRA_GEOSERVER_OPTS which gets appended to GEOSERVER_OPTS would avoid this.

Note: Dockerfile#L98 defines JAVA_OPTS, though catalina.sh suggests to rather use CATALINA_OPTS instead of JAVA_OPTS

SLD styles can't be edit with non-root user image.

After building a geoserver image with the custom_build.sh, and running a container with. we face an issue with the SLD style, that can't be created, edited, or modified.

I have tested the same scenario with an image from the docker hub, running under root user the result was different, and everything works fine.

Error from latest image

I get the next error from docker-hub:

cp: cannot stat '/geoserver_data/data/security/role/geonode REST role service/config.xml': No such file or directory

NGINX configuration - `proxy_temp_file_write_size` must be equal or higher than `proxy_buffer_size`

When building the Geoserver image (as it is right now), the NGINX reverse proxy container will build but it will fail to start with the following error message.

2023-07-25 12:54:52 2023/07/25 10:54:52 [emerg] 1#1: "proxy_temp_file_write_size" must be equal to or greater than the maximum of the value of "proxy_buffer_size" and one of the "proxy_buffers" in /etc/nginx/nginx.conf:32
2023-07-25 12:54:52 nginx: [emerg] "proxy_temp_file_write_size" must be equal to or greater than the maximum of the value of "proxy_buffer_size" and one of the "proxy_buffers" in /etc/nginx/nginx.conf:32

The proxy_temp_file_write_size is now set to 32kb and according to the error message it should be raised to be at least 256kb, the current value.

Container doesn't stop on SIGINT

The container needs to stop on SIGINT (CTRL+C)

How to reproduce

  1. Start the container using docker run --rm -p 8080:8080 geosolutionsit/geoserver:2.19.1
  2. Waiting to see:
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [30964] milliseconds
catalina.sh run
  1. Doing SIGINT doing CTRL+C, you'll see something like: ^C^C^C^C^C^C^C^C^C^C (one for each time you send it)

Expected behavior

The container stop on receiving SIGINT

Actual behavior

SIGINT isn't handled and the container needs to be stopped using docker stop via another terminal

Workaround

Starting the container using --init flag: docker run --rm --init -p 8080:8080 geosolutionsit/geoserver:2.19.1

Possible fix

  • updating the documentation about --init flag
  • using an init directly inside the container like s6-overlay

Additional information

Wrong encoding for file geoserver-plugin-download.sh

Wrong encoding for file geoserver-plugin-download.sh

[+] Building 5.5s (18/37)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
 => => transferring dockerfile: 5.70kB                                                                                                                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                       0.0s
 => => transferring context: 53B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/tomcat:9-jdk11-openjdk                                                                                                                                                               4.4s
 => [auth] library/tomcat:pull token for registry-1.docker.io                                                                                                                                                                           0.0s
 => https://build.geoserver.org/geoserver/main/geoserver-main-latest-war.zip                                                                                                                                                            0.4s
 => [mother  1/15] FROM docker.io/library/tomcat:9-jdk11-openjdk@sha256:2a335cf8a9f43a885227cc3cb927dccadcd22e075d4f2b0bc1e6d5668e744fa0                                                                                                0.0s
 => [internal] load build context                                                                                                                                                                                                       0.1s
 => => transferring context: 87.47kB                                                                                                                                                                                                    0.0s
 => CACHED [mother  2/15] RUN apt-get update && apt-get install -y unzip wget cmake nasm    && wget https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz     && tar -zxf ./libjpeg-turbo-2.0.6.tar.gz  0.0s
 => CACHED [mother  3/15] WORKDIR /output/datadir                                                                                                                                                                                       0.0s
 => CACHED [mother  4/15] ADD ./.placeholder ./                                                                                                                                                                                         0.0s
 => CACHED [mother  5/15] WORKDIR /output/webapp                                                                                                                                                                                        0.0s
 => CACHED [mother  6/15] ADD https://build.geoserver.org/geoserver/main/geoserver-main-latest-war.zip ./                                                                                                                               0.0s
 => CACHED [mother  7/15] RUN     if [ -f "./download" ] ; then       mv download geoserver.war.zip && unzip geoserver.war.zip -d geoserver.war && mkdir -p ./geoserver && unzip ./geoserver.war/geoserver.war -d ./geoserver && rm -r  0.0s
 => CACHED [mother  8/15] RUN     if [ "${GEOSERVER_WEBAPP_SRC##*.}" = "zip" ]; then         unzip "./*zip";         rm ./*zip;     fi     && [ -d "./geoserver" ] || (mkdir -p ./geoserver && unzip ./geoserver.war -d ./geoserver &&  0.0s
 => CACHED [mother  9/15] WORKDIR /output/plugins                                                                                                                                                                                       0.0s
 => CACHED [mother 10/15] ADD .placeholder  /output/plugins/                                                                                                                                                                            0.0s
 => CACHED [mother 11/15] COPY geoserver-plugin-download.sh /usr/local/bin/geoserver-plugin-download.sh                                                                                                                                 0.0s
 => ERROR [mother 12/15] RUN /usr/local/bin/geoserver-plugin-download.sh /output/plugins/                                                                                                                                               0.5s
------
 > [mother 12/15] RUN /usr/local/bin/geoserver-plugin-download.sh /output/plugins/ :
#20 0.437 /usr/bin/env: ‘bash\r’: No such file or directory
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/bash -c /usr/local/bin/geoserver-plugin-download.sh /output/plugins/ ${PLUG_IN_URLS}]: exit code: 127```

Cannot customize the admin password

Starting the container with something like:

docker run -it -p 8083:8080 -e ADMIN_PASSWORD='Geos' geosolutionsit/geoserver

fails to customize the password, in the logs I can see:

/usr/bin/env: ‘bash\r’: No such file or directory

Doesn't seem to work on Mac Monerey

It started with it just spinning on startup waiting for geoserver to start with a host platform warning.

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running

I found some information that said I should try --platform linux/amd64 which I did

docker run --name gs --detach -p 8080:8080 --platform linux/amd64 geosolutionsit/geoserver

Now it seems to "start" as far as the logs are concerned but I can't get to

http://localhost:8080/geoserver

I tried just downloading the Tomcat Docker image on it's own and spinning it up. I can get to the same ports so it isn't some kind of network/firewall issue that I can see.

Current "It seems like it started" Logs

Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
Waiting for GeoServer to be Up and running
07-Feb-2022 17:37:29.989 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
Waiting for GeoServer to be Up and running
07-Feb-2022 17:37:30.132 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [3449] milliseconds
07-Feb-2022 17:37:30.447 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
07-Feb-2022 17:37:30.448 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.58]
07-Feb-2022 17:37:30.482 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/geoserver]

Build of docker image for GeoServer 2.22.4 is failing

There's a problem in the build during the download of the war file from SourceForge. The link is working fine in the browser.
It needs to be debugged by building the image locally

2023-06-22T09:23:03Z #10 https://netcologne.dl.sourceforge.net/project/geoserver/GeoServer/2.22.4/geoserver-2.22.4-war.zip
2023-06-22T09:23:03Z #10 DONE 0.6s
2023-06-22T09:23:03Z
2023-06-22T09:23:03Z #11 [mother 6/15] ADD https://netcologne.dl.sourceforge.net/project/geoserver/GeoServer/2.22.4/geoserver-2.22.4-war.zip ./
2023-06-22T09:23:03Z #11 DONE 0.2s
2023-06-22T09:23:03Z
2023-06-22T09:23:03Z #12 [mother 7/15] RUN if [ -f "./download" ] ; then mv download geoserver.war.zip && unzip geoserver.war.zip -d geoserver.war && mkdir -p ./geoserver && unzip ./geoserver.war/geoserver.war -d ./geoserver && rm -rf ./geoserver.war; fi
2023-06-22T09:23:04Z #12 DONE 0.5s
2023-06-22T09:23:04Z
2023-06-22T09:23:04Z #13 [mother 8/15] RUN if [ "${GEOSERVER_WEBAPP_SRC##*.}" = "zip" ]; then unzip "./*zip"; rm ./*zip; fi && [ -d "./geoserver" ] || (mkdir -p ./geoserver && unzip ./geoserver.war -d ./geoserver && rm ./geoserver.war)
2023-06-22T09:23:04Z #13 0.508 Archive: ./geoserver-2.22.4-war.zip
2023-06-22T09:23:04Z #13 0.508 End-of-central-directory signature not found. Either this file is not
2023-06-22T09:23:04Z #13 0.508 a zipfile, or it constitutes one disk of a multi-part archive. In the
2023-06-22T09:23:04Z #13 0.508 latter case the central directory and zipfile comment will be found on
2023-06-22T09:23:04Z #13 0.508 the last disk(s) of this archive.
2023-06-22T09:23:04Z #13 0.508 unzip: cannot find zipfile directory in one of ./*zip or
2023-06-22T09:23:04Z #13 0.508 ./*zip.zip, and cannot find ./geoserver-2.22.4-war.zip.ZIP, period.

docker build --build-arg GEOSERVER_WEBAPP_SRC=https://netcologne.dl.sourceforge.net/project/geoserver/GeoServer/2.22.4/geoserver-2.22.4-war.zip --build-arg PLUG_IN_PATHS=./resources/geoserver-plugins -f Dockerfile -t index.docker.io/geosolutionsit/geoserver:2.22.4 .

Docker buildkit enabled prevents download of `openjdk`

This problem was found on Docker version 24.0.2, running on a Windows machine but in a Linux Ubuntu 22.04.2 LTS version with wsl.

As highlighted in this SO issue
https://stackoverflow.com/questions/65361083/docker-build-failed-to-fetch-oauth-token-for-openjdk

The Docker buildkit, enabled by default on Windows, prevents the install of openJDK.
error message is

 => [geoserver internal] load build definition from Dockerfile                                                                                                                                                                          0.1s
 => => transferring dockerfile: 5.78kB                                                                                                                                                                                                  0.0s
 => [geoserver internal] load .dockerignore                                                                                                                                                                                             0.1s
 => => transferring context: 53B                                                                                                                                                                                                        0.0s
 => ERROR [geoserver internal] load metadata for docker.io/library/tomcat:9-jdk11-openjdk                                                                                                                                              10.5s
 => [geoserver auth] library/tomcat:pull token for registry-1.docker.io                                                                                                                                                                 0.0s
------
 > [geoserver internal] load metadata for docker.io/library/tomcat:9-jdk11-openjdk:
------
failed to solve: tomcat:9-jdk11-openjdk: failed to authorize: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp: lookup auth.docker.io on 172.30.96.1:53: read udp 10.200.10.1:52167->172.30.96.1:53: i/o timeout
acristofori@DESKTOP-4SNP92D:/mnt/c/Users/acristofori/Development/docker-geoserver$

To workaround this issue we need to set two environment variables before running docker-compose up. These environment variables when set disable docker toolkit

export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.