From 4d96f6f19c82ab7106f57ffd38a06d8f444cc6c4 Mon Sep 17 00:00:00 2001 From: Andre Henn Date: Mon, 11 Dec 2023 14:20:01 +0100 Subject: [PATCH 1/2] introduce health checks for GeoServer and postgis --- Dockerfile | 4 ++++ README.md | 1 + docker-compose-demo.yml | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4bd8921..1814cac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -95,6 +95,7 @@ ENV ROOT_WEBAPP_REDIRECT=false ENV POSTGRES_JNDI_ENABLED=false ENV CONFIG_DIR=/opt/config ENV CONFIG_OVERRIDES_DIR=/opt/config_overrides +ENV HEALTHCHECK_URL=http://localhost:8080/geoserver/web/wicket/resource/org.geoserver.web.GeoServerBasePage/img/logo.png EXPOSE 8080 @@ -126,3 +127,6 @@ RUN chmod +x /opt/*.sh ENTRYPOINT ["/opt/startup.sh"] WORKDIR /opt + +HEALTHCHECK --interval=1m --timeout=20s --retries=3 \ + CMD curl --fail $HEALTHCHECK_URL || exit 1 diff --git a/README.md b/README.md index 00fb04a..91bccdd 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ Following is the list of the all the environment variables that can be passed do | ADDITIONAL_FONTS_DIR | Sets the directory for additional fonts used by GeoServer | `/opt/additional_fonts/` | | 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` | 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 | diff --git a/docker-compose-demo.yml b/docker-compose-demo.yml index 72a2492..03b8b85 100644 --- a/docker-compose-demo.yml +++ b/docker-compose-demo.yml @@ -8,7 +8,7 @@ services: - CORS_ENABLED=true - CORS_ALLOWED_METHODS=GET,POST,PUT,HEAD,OPTIONS ports: - - 80:8080 + - "80:8080" environment: - INSTALL_EXTENSIONS=true - STABLE_EXTENSIONS=wps,csw @@ -32,3 +32,8 @@ services: POSTGRES_PASSWORD: geoserver volumes: - ./postgis/postgresql_data:/var/lib/postgresql/data:Z + healthcheck: + test: pg_isready -U geoserver -h localhost -t 5 || exit 1 + interval: 10s + retries: 5 + timeout: 10s From 9b80e8c4103ba2a78b7846b396e3f7e2e6cda1d1 Mon Sep 17 00:00:00 2001 From: Andre Henn Date: Wed, 20 Dec 2023 12:30:10 +0100 Subject: [PATCH 2/2] feat: adds health check (default values) to docker-compose file --- docker-compose-demo.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker-compose-demo.yml b/docker-compose-demo.yml index 03b8b85..8de1fc4 100644 --- a/docker-compose-demo.yml +++ b/docker-compose-demo.yml @@ -23,6 +23,11 @@ services: volumes: - ./geoserver_data:/opt/geoserver_data/:Z - ./additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup + healthcheck: + test: curl --fail "http://localhost:8080/geoserver/web/wicket/resource/org.geoserver.web.GeoServerBasePage/img/logo.png" || exit 1 + interval: 1m + retries: 3 + timeout: 20s postgis: image: postgis/postgis:16-3.4-alpine ports: