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..8de1fc4 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 @@ -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: @@ -32,3 +37,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