Merge pull request #38 from ahennr/docker-setup-hardening

Introduce health checks for GeoServer (and postgis db in demo)
pull/41/head
Nils Bühner 2023-12-20 13:41:50 +01:00 committed by GitHub
commit 8f9edd5503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -95,6 +95,7 @@ ENV ROOT_WEBAPP_REDIRECT=false
ENV POSTGRES_JNDI_ENABLED=false ENV POSTGRES_JNDI_ENABLED=false
ENV CONFIG_DIR=/opt/config ENV CONFIG_DIR=/opt/config
ENV CONFIG_OVERRIDES_DIR=/opt/config_overrides 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 EXPOSE 8080
@ -126,3 +127,6 @@ RUN chmod +x /opt/*.sh
ENTRYPOINT ["/opt/startup.sh"] ENTRYPOINT ["/opt/startup.sh"]
WORKDIR /opt WORKDIR /opt
HEALTHCHECK --interval=1m --timeout=20s --retries=3 \
CMD curl --fail $HEALTHCHECK_URL || exit 1

View File

@ -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/` | | 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` | | 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` | | 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). 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 | | VAR NAME | DESCRIPTION | SAMPLE VALUE |

View File

@ -8,7 +8,7 @@ services:
- CORS_ENABLED=true - CORS_ENABLED=true
- CORS_ALLOWED_METHODS=GET,POST,PUT,HEAD,OPTIONS - CORS_ALLOWED_METHODS=GET,POST,PUT,HEAD,OPTIONS
ports: ports:
- 80:8080 - "80:8080"
environment: environment:
- INSTALL_EXTENSIONS=true - INSTALL_EXTENSIONS=true
- STABLE_EXTENSIONS=wps,csw - STABLE_EXTENSIONS=wps,csw
@ -23,6 +23,11 @@ services:
volumes: volumes:
- ./geoserver_data:/opt/geoserver_data/:Z - ./geoserver_data:/opt/geoserver_data/:Z
- ./additional_libs:/opt/additional_libs:Z # by mounting this we can install libs from host on startup - ./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: postgis:
image: postgis/postgis:16-3.4-alpine image: postgis/postgis:16-3.4-alpine
ports: ports:
@ -32,3 +37,8 @@ services:
POSTGRES_PASSWORD: geoserver POSTGRES_PASSWORD: geoserver
volumes: volumes:
- ./postgis/postgresql_data:/var/lib/postgresql/data:Z - ./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