From 1f39bfe152d3cd554f64313c94d921503de38b19 Mon Sep 17 00:00:00 2001 From: William Condori Date: Thu, 29 Sep 2022 11:59:13 -0500 Subject: [PATCH] Add support to change tomcat default HTTP port --- Dockerfile | 1 + README.md | 51 +++++++++++++++++++++++++++++++-------------------- startup.sh | 6 ++++++ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5086810..0e53b6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,7 @@ ENV STABLE_PLUGIN_URL=$STABLE_PLUGIN_URL ENV ADDITIONAL_LIBS_DIR=/opt/additional_libs/ ENV ADDITIONAL_FONTS_DIR=/opt/additional_fonts/ ENV SKIP_DEMO_DATA=false +ENV TOMCAT_HTTP_PORT=8080 # see https://docs.geoserver.org/stable/en/user/production/container.html ENV CATALINA_OPTS="\$EXTRA_JAVA_OPTS \ diff --git a/README.md b/README.md index a7470d6..d2fb315 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,20 @@ This Dockerfile can be used to create images for all geoserver versions since 2.5. -* Debian based Linux -* OpenJDK 11 -* Tomcat 9 -* GeoServer - * Support of custom fonts (e.g. for SLD styling) - * CORS support - * Support extensions - * Support additional libraries +- Debian based Linux +- OpenJDK 11 +- Tomcat 9 +- GeoServer + - Support of custom fonts (e.g. for SLD styling) + - CORS support + - Support extensions + - Support additional libraries ## How to Use ### How to run official release? -To pull an official image use ``docker.osgeo.org/geoserver:{{VERSION}}``, e.g.: +To pull an official image use `docker.osgeo.org/geoserver:{{VERSION}}`, e.g.: ``` docker pull docker.osgeo.org/geoserver:2.21.1 @@ -36,7 +36,7 @@ docker run -d -p 80:8080 docker.osgeo.org/geoserver:2.21.1 Check http://localhost/geoserver to see the geoserver page, and login with geoserver default `admin:geoserver` credentials. -**IMPORTANT NOTE:** Please change the default ``geoserver`` and ``master`` passwords. +**IMPORTANT NOTE:** Please change the default `geoserver` and `master` passwords. For more information see the user-guide [docker installation instructions](https://docs.geoserver.org/latest/en/user/installation/docker.html). @@ -44,7 +44,6 @@ For more information see the user-guide [docker installation instructions](https To use an external folder as your geoserver data directory. - ``` docker run -it -p 80:8080 \ --mount src="/absolute/path/on/host",target=/opt/geoserver_data/,type=bind \ @@ -61,11 +60,11 @@ The environment variable `SKIP_DEMO_DATA` can be set to `true` to create an empt ### How to download and install additional extensions on startup? -The ``startup.sh`` script allows some customization on startup: +The `startup.sh` script allows some customization on startup: -* ``INSTALL_EXTENSIONS`` to ``true`` to download and install extensions -* ``STABLE_EXTENSIONS`` list of extensions to download and install -* ``CORS_ENABLED`` +- `INSTALL_EXTENSIONS` to `true` to download and install extensions +- `STABLE_EXTENSIONS` list of extensions to download and install +- `CORS_ENABLED` Example installing wps and ysld extensions: @@ -112,11 +111,21 @@ docker run -it -p 80:8080 \ **Note:** Do not change the target value! +### How to change Tomcat default port? + +If you want to change the default Tomcat port (8080) to e.g. 80, you can use: + +``` +docker run -it -p 80:80 \ + --env TOMCAT_HTTP_PORT=80 \ + docker.osgeo.org/geoserver:2.21.1 +``` + ## Troubleshooting ### How to watch geoserver.log from host? -To watch ``geoserver.log`` of a running container: +To watch `geoserver.log` of a running container: ``` docker exec -it {CONTAINER_ID} tail -f /opt/geoserver_data/logs/geoserver.log @@ -124,11 +133,11 @@ docker exec -it {CONTAINER_ID} tail -f /opt/geoserver_data/logs/geoserver.log ### How to use the docker-compose demo? -The ``docker-compose-demo.yml`` to build with your own data directory and extensions. +The `docker-compose-demo.yml` to build with your own data directory and extensions. -Stage geoserver data directory contents into ``geoserver_data``, and any extensions into ``additional_libs`` folder. +Stage geoserver data directory contents into `geoserver_data`, and any extensions into `additional_libs` folder. -Run ``docker-compose``: +Run `docker-compose`: ``` docker-compose -f docker-compose-demo.yml up --build @@ -136,7 +145,6 @@ docker-compose -f docker-compose-demo.yml up --build ## How to Build? - ### How to build a local image? ``` @@ -199,16 +207,19 @@ docker build \ OSGeo maintains geoserver-docker.osgeo.org repository for publishing. The results are combined into docker.osgeo.org repository alongside other software such as PostGIS. Build locally: + ``` docker build -t geoserver-docker.osgeo.org/geoserver:2.21.1 . ``` Login using with osgeo user id: + ``` docker login geoserver-docker.osgeo.org ``` Push to osgeo repository: + ``` docker push geoserver-docker.osgeo.org/geoserver:2.21.1 ``` diff --git a/startup.sh b/startup.sh index b8a3ec8..ea5826f 100755 --- a/startup.sh +++ b/startup.sh @@ -60,5 +60,11 @@ if [ "${CORS_ENABLED}" = "true" ]; then fi fi +# replace the default port with the one provided by the environment variable +if [ ! -z "$TOMCAT_HTTP_PORT" ]; then + echo "Tomcat HTTP port set to $TOMCAT_HTTP_PORT" + sed -i "s/port=\"[0-9]\+\" protocol=\"HTTP\/1.1\"/port=\"$TOMCAT_HTTP_PORT\" protocol=\"HTTP\/1.1\"/" $CATALINA_HOME/conf/server.xml +fi + # start the tomcat $CATALINA_HOME/bin/catalina.sh run