From a9021f6a675536fdee2d5ed61d06c9036bc6e3af Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Mon, 21 Oct 2024 12:39:38 -0300 Subject: [PATCH] Update config service to use the embedded /etc/geoserver config by default --- compose/.env | 1 - compose/acceptance.yml | 4 +- compose/compose.yml | 16 ++-- compose/standalone.yml | 6 -- docs/configuration/index.md | 6 +- docs/deploy/docker-compose/index.md | 4 +- .../compose.yml} | 51 ++--------- .../{docker-compose.yml => compose.yml} | 88 +++++++------------ .../stable/pgconfig/compose.yml | 30 ++----- docs/develop/index.md | 4 +- src/apps/infrastructure/config/Dockerfile | 18 +++- 11 files changed, 80 insertions(+), 148 deletions(-) rename docs/deploy/docker-compose/stable/{shared_datadir/docker-compose.yml => datadir/compose.yml} (76%) rename docs/deploy/docker-compose/stable/jdbcconfig/{docker-compose.yml => compose.yml} (71%) diff --git a/compose/.env b/compose/.env index ad0a8bfa1..48d629c82 100644 --- a/compose/.env +++ b/compose/.env @@ -23,7 +23,6 @@ DISCOVERY_SERVER_DEFAULT_PROFILES=${LOGGING_PROFILE} # For more information, see https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_git_backend CONFIG_SERVER_DEFAULT_PROFILES=${LOGGING_PROFILE},native,standalone - JAVA_OPTS_DEFAULT=-XX:MaxRAMPercentage=80 -XshowSettings:system -Dlogging.config=file:/etc/geoserver/logback-spring.xml JAVA_OPTS_DISCOVERY=$JAVA_OPTS_DEFAULT diff --git a/compose/acceptance.yml b/compose/acceptance.yml index 155e3e155..4d99a950c 100644 --- a/compose/acceptance.yml +++ b/compose/acceptance.yml @@ -72,13 +72,13 @@ services: resources: limits: cpus: "1.0" - memory: 512M + memory: 256M config: deploy: resources: limits: cpus: "1.0" - memory: 512M + memory: 256M wms: deploy: resources: diff --git a/compose/compose.yml b/compose/compose.yml index 0cb8a0834..945e28a92 100644 --- a/compose/compose.yml +++ b/compose/compose.yml @@ -52,9 +52,6 @@ services: rabbitmq: condition: service_healthy required: true - ports: - - 9000:8080 - - 9001:8081 deploy: resources: limits: @@ -70,21 +67,18 @@ services: environment: JAVA_OPTS: "${JAVA_OPTS_CONFIG}" SPRING_PROFILES_ACTIVE: "${CONFIG_SERVER_DEFAULT_PROFILES}" - # 'git' profile config - CONFIG_GIT_URI: https://github.com/geoserver/geoserver-cloud-config - CONFIG_GIT_BASEDIR: /tmp/git_config - # 'native' profile config - CONFIG_NATIVE_PATH: /tmp/config restart: unless-stopped volumes: - - config:/tmp/config + # override with the local copy to test config changes during development + - config:/etc/geoserver ports: + # not needed in production, exposed for local development - 8888:8080 deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Eureka service discovery. This is a Discovery First Bootstrap configuration. # The discovery service is the only fixed entry point. @@ -104,7 +98,7 @@ services: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Application facade, provides a single entry point routing to all # microservices (e.g. http://localhost:9090/geoserver/wms, http://localhost:9090/geoserver/wfs, etc) diff --git a/compose/standalone.yml b/compose/standalone.yml index 728b083f2..42814b2a9 100644 --- a/compose/standalone.yml +++ b/compose/standalone.yml @@ -4,20 +4,14 @@ services: discovery: restart: no - environment: - SPRING_PROFILES_ACTIVE: "standalone" entrypoint: echo "discovery-service disabled." config: restart: no - environment: - SPRING_PROFILES_ACTIVE: "standalone" entrypoint: echo "config-service disabled." admin: restart: no - environment: - SPRING_PROFILES_ACTIVE: "standalone" entrypoint: echo "admin-service disabled for standalone mode, requires discovery-service." gateway: diff --git a/docs/configuration/index.md b/docs/configuration/index.md index acd535783..8bdd646b7 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -84,13 +84,13 @@ geotools: nonProxyHosts: ${https.nonProxyHosts:${geotools.httpclient.proxy.http.nonProxyHosts}} ``` -### Configure HTTP proxy with environment variables in docker-compose.yml +### Configure HTTP proxy with environment variables in compose.yml As mentioned above, regular JVM proxy configuration works with Java System properties but not with Operating System environment variables. The above `geotools.httpclient.proxy` config properties though allow to do so -easily as in the following `docker-compose.yml` snippet: +easily as in the following `compose.yml` snippet: ```yaml version: "3.8" @@ -142,4 +142,4 @@ To use GeoServer ACL with GeoServer Cloud, you need to do the following steps: ## Use OAuth authentication -You can enable OAuth authentication by replacing the default `gateway` image by the geOrchestra gateway (for example `georchestra/gateway:23.1-RC1`). \ No newline at end of file +You can enable OAuth authentication by replacing the default `gateway` image by the geOrchestra gateway (for example `georchestra/gateway:23.1-RC1`). diff --git a/docs/deploy/docker-compose/index.md b/docs/deploy/docker-compose/index.md index 150916016..81fe84e94 100644 --- a/docs/deploy/docker-compose/index.md +++ b/docs/deploy/docker-compose/index.md @@ -9,8 +9,8 @@ These instructions assume you have Docker Engine, Docker CLI, and the [Compose P Here are three `docker compose` based deployment examples to try out: * Our preferred option, the [pgconfig](stable/pgconfig/compose.yml) Catalog back-end, specifically developed for GeoServer Cloud with scalability in mind, storing all Catalog and GeoServer configuration in a PostgreSQL database. - * A shared [data-directory](stable/shared_datadir/docker-compose.yml) option, using a mounted volume to share a traditional GeoServer data directory across all services. - * And a **deprecated** [jdbcconfig](jdbcconfig/docker-compose.yml) option, using the GeoServer [jdbcconfig](https://docs.geoserver.org/main/en/user/community/jdbcconfig/index.html) and [jdbcstore](https://docs.geoserver.org/main/en/user/community/jdbcstore/index.html) community modules. + * A shared [data-directory](stable/datadir/compose.yml) option, using a mounted volume to share a traditional GeoServer data directory across all services. + * And a **deprecated** [jdbcconfig](jdbcconfig/compose.yml) option, using the GeoServer [jdbcconfig](https://docs.geoserver.org/main/en/user/community/jdbcconfig/index.html) and [jdbcstore](https://docs.geoserver.org/main/en/user/community/jdbcstore/index.html) community modules. Open a terminal and enter the directory where you just downloaded that file, and run `docker compose pull` to fetch the docker images from [Dockerhub](https://hub.docker.com/u/geoservercloud/): diff --git a/docs/deploy/docker-compose/stable/shared_datadir/docker-compose.yml b/docs/deploy/docker-compose/stable/datadir/compose.yml similarity index 76% rename from docs/deploy/docker-compose/stable/shared_datadir/docker-compose.yml rename to docs/deploy/docker-compose/stable/datadir/compose.yml index 29f06754b..4bbdfcedd 100644 --- a/docs/deploy/docker-compose/stable/shared_datadir/docker-compose.yml +++ b/docs/deploy/docker-compose/stable/datadir/compose.yml @@ -10,9 +10,6 @@ volumes: #device: $PWD/datadir rabbitmq_data: # volume for rabbitmq data, so it doesn't create an anonymous one on each container geowebcache_data: # used by gwc and web-ui to locate the default gwc tile cache directory - -networks: - gs-cloud-network: services: rabbitmq: @@ -21,31 +18,23 @@ services: restart: unless-stopped volumes: - rabbitmq_data:/var/lib/rabbitmq - networks: - - gs-cloud-network deploy: resources: limits: cpus: '2.0' memory: 1G - # Eureka service discovery. This is a Discovery First Bootstrap configuration. - # The discovery service is the only fixed entry point. - # Browse to http://localhost:8761 to check all services are registered. - # Run docker compose -f docker-compose.yml -f docker-compose-discovery-ha.yml to run extra discovery service instances for HA discovery: image: geoservercloud/geoserver-cloud-discovery:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as ports: - 8761:8761 - networks: - - gs-cloud-network restart: unless-stopped deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Spring Cloud Config service, provides centralized configuration to all # microservices. Being a Discovery First Bootstrap configuration, it'll @@ -57,30 +46,20 @@ services: - discovery - rabbitmq environment: - # Either 'git' or 'native'. Use the default sample git repository to download the services configuration from - # If 'git', BEWARE config server will look for a branch called "master", and github changed the default branch name to "main" - # For more information, see https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_git_backend - SPRING_PROFILES_ACTIVE: git - # 'git' profile config - CONFIG_GIT_URI: https://github.com/geoserver/geoserver-cloud-config.git - # get the config for this release from the v1.8.12 tag + # default to `native` loading the config embedded in /etc/geoserver + # use `git` to fetch the config from a git reposiroty, and CONFIG_GIT_URI to change + # the default repository https://github.com/geoserver/geoserver-cloud-config.git + SPRING_PROFILES_ACTIVE: native + # If using the `git` profile, get the config from this tag SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL: v1.8.12 - # where to store the cloned repository, if unset, it'll use /tmp/config-repo- - CONFIG_GIT_BASEDIR: /tmp/git_config - # 'native' profile config - CONFIG_NATIVE_PATH: /tmp/config - # avoid stack trace due to jgit not being able of creating a .config dir at $HOME - XDG_CONFIG_HOME: /tmp - networks: - - gs-cloud-network # Uncoment to bind to a local filesystem directory if using the 'native' profile #volumes: - # - ./config:/tmp/config + # - ./config:/etc/geoserver deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Application facade, provides a single entry point routing to all # microservices (e.g. http://localhost:9090/geoserver/cloud/wms, http://localhost:9090/geoserver/cloud/wfs, etc) @@ -94,8 +73,6 @@ services: GEOSERVER_BASE_PATH: /geoserver/cloud ports: - 9090:8080 - networks: - - gs-cloud-network deploy: resources: limits: @@ -113,8 +90,6 @@ services: GEOSERVER_DATA_DIR: /opt/app/data_directory volumes: - shared_data_directory:/opt/app/data_directory - networks: - - gs-cloud-network deploy: resources: limits: @@ -134,8 +109,6 @@ services: volumes: - shared_data_directory:/opt/app/data_directory - geowebcache_data:/data/geowebcache - networks: - - gs-cloud-network deploy: resources: limits: @@ -153,8 +126,6 @@ services: GEOSERVER_DATA_DIR: /opt/app/data_directory volumes: - shared_data_directory:/opt/app/data_directory - networks: - - gs-cloud-network deploy: resources: limits: @@ -172,8 +143,6 @@ services: GEOSERVER_DATA_DIR: /opt/app/data_directory volumes: - shared_data_directory:/opt/app/data_directory - networks: - - gs-cloud-network deploy: mode: replicated replicas: 1 @@ -195,8 +164,6 @@ services: volumes: - shared_data_directory:/opt/app/data_directory - geowebcache_data:/data/geowebcache - networks: - - gs-cloud-network deploy: resources: limits: @@ -211,8 +178,6 @@ services: SPRING_PROFILES_ACTIVE: "datadir" GEOSERVER_DATA_DIR: /opt/app/data_directory GEOWEBCACHE_CACHE_DIR: /data/geowebcache - networks: - - gs-cloud-network volumes: - shared_data_directory:/opt/app/data_directory - geowebcache_data:/data/geowebcache diff --git a/docs/deploy/docker-compose/stable/jdbcconfig/docker-compose.yml b/docs/deploy/docker-compose/stable/jdbcconfig/compose.yml similarity index 71% rename from docs/deploy/docker-compose/stable/jdbcconfig/docker-compose.yml rename to docs/deploy/docker-compose/stable/jdbcconfig/compose.yml index 65da57467..3fab6f884 100644 --- a/docs/deploy/docker-compose/stable/jdbcconfig/docker-compose.yml +++ b/docs/deploy/docker-compose/stable/jdbcconfig/compose.yml @@ -2,9 +2,6 @@ volumes: postgresql_config_data: # volume for postgresql data, used to store the geoserver config through jdbcconfig rabbitmq_data: # volume for rabbitmq data, so it doesn't create an anonymous one on each container geowebcache_data: # used by gwc and web-ui to locate the default gwc tile cache directory - -networks: - gs-cloud-network: services: rabbitmq: @@ -13,8 +10,6 @@ services: restart: unless-stopped volumes: - rabbitmq_data:/var/lib/rabbitmq - networks: - - gs-cloud-network deploy: resources: limits: @@ -23,13 +18,11 @@ services: database: # be sure geoserver.backend.jdbcconfig.initdb is set to true in application.yml at lease for the first app run - image: postgres:13-alpine + image: postgres:15-alpine environment: POSTGRES_DB: geoserver_config POSTGRES_USER: geoserver POSTGRES_PASSWORD: geo5erver - networks: - - gs-cloud-network volumes: - postgresql_config_data:/var/lib/postgresql/data deploy: @@ -38,23 +31,15 @@ services: cpus: '2.0' memory: 1G - # Eureka service discovery. This is a Discovery First Bootstrap configuration. - # The discovery service is the only fixed entry point. - # Browse to http://localhost:8761 to check all services are registered. - # Run docker compose -f docker-compose.yml -f docker-compose-discovery-ha.yml to run extra discovery service instances for HA discovery: image: geoservercloud/geoserver-cloud-discovery:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as - ports: - - 8761:8761 - networks: - - gs-cloud-network restart: unless-stopped deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Spring Cloud Config service, provides centralized configuration to all # microservices. Being a Discovery First Bootstrap configuration, it'll @@ -65,32 +50,21 @@ services: depends_on: - discovery - rabbitmq - - database environment: - # Either 'git' or 'native'. Use the default sample git repository to download the services configuration from - # If 'git', BEWARE config server will look for a branch called "master", and github changed the default branch name to "main" - # For more information, see https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_git_backend - SPRING_PROFILES_ACTIVE: git - # 'git' profile config - CONFIG_GIT_URI: https://github.com/geoserver/geoserver-cloud-config.git - # get the config for this release from the v1.8.12 tag + # default to `native` loading the config embedded in /etc/geoserver + # use `git` to fetch the config from a git reposiroty, and CONFIG_GIT_URI to change + # the default repository https://github.com/geoserver/geoserver-cloud-config.git + SPRING_PROFILES_ACTIVE: native + # If using the `git` profile, get the config from this tag SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL: v1.8.12 - # where to store the cloned repository, if unset, it'll use /tmp/config-repo- - CONFIG_GIT_BASEDIR: /tmp/git_config - # 'native' profile config - CONFIG_NATIVE_PATH: /tmp/config - # avoid stack trace due to jgit not being able of creating a .config dir at $HOME - XDG_CONFIG_HOME: /tmp - networks: - - gs-cloud-network # Uncoment to bind to a local filesystem directory if using the 'native' profile #volumes: - # - ./config:/tmp/config + # - ./config:/etc/geoserver deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Application facade, provides a single entry point routing to all # microservices (e.g. http://localhost:9090/geoserver/cloud/wms, http://localhost:9090/geoserver/cloud/wfs, etc) @@ -104,8 +78,6 @@ services: GEOSERVER_BASE_PATH: /geoserver/cloud ports: - 9090:8080 - networks: - - gs-cloud-network deploy: resources: limits: @@ -117,11 +89,12 @@ services: image: geoservercloud/geoserver-cloud-wfs:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - config + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" - networks: - - gs-cloud-network deploy: resources: limits: @@ -133,14 +106,15 @@ services: image: geoservercloud/geoserver-cloud-wms:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - config + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" GEOWEBCACHE_CACHE_DIR: /data/geowebcache volumes: - geowebcache_data:/data/geowebcache - networks: - - gs-cloud-network deploy: resources: limits: @@ -152,11 +126,12 @@ services: image: geoservercloud/geoserver-cloud-wcs:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - config + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" - networks: - - gs-cloud-network deploy: resources: limits: @@ -168,11 +143,12 @@ services: image: geoservercloud/geoserver-cloud-rest:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - config + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" - networks: - - gs-cloud-network deploy: mode: replicated replicas: 1 @@ -186,14 +162,15 @@ services: image: geoservercloud/geoserver-cloud-webui:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - rabbitmq + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" GEOWEBCACHE_CACHE_DIR: /data/geowebcache volumes: - geowebcache_data:/data/geowebcache - networks: - - gs-cloud-network deploy: resources: limits: @@ -203,12 +180,13 @@ services: image: geoservercloud/geoserver-cloud-gwc:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as depends_on: - - config + config: + condition: service_started + database: + condition: service_started environment: SPRING_PROFILES_ACTIVE: "jdbcconfig" GEOWEBCACHE_CACHE_DIR: /data/geowebcache - networks: - - gs-cloud-network volumes: - geowebcache_data:/data/geowebcache deploy: diff --git a/docs/deploy/docker-compose/stable/pgconfig/compose.yml b/docs/deploy/docker-compose/stable/pgconfig/compose.yml index cc601dbfb..45d1ff436 100644 --- a/docs/deploy/docker-compose/stable/pgconfig/compose.yml +++ b/docs/deploy/docker-compose/stable/pgconfig/compose.yml @@ -74,10 +74,6 @@ services: cpus: '4.0' memory: 2G - # Eureka service discovery. This is a Discovery First Bootstrap configuration. - # The discovery service is the only fixed entry point. - # Browse to http://localhost:8761 to check all services are registered. - # Run docker compose -f docker-compose.yml -f docker-compose-discovery-ha.yml to run extra discovery service instances for HA discovery: image: geoservercloud/geoserver-cloud-discovery:1.8.12 user: 1000:1000 @@ -89,7 +85,7 @@ services: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Spring Cloud Config service, provides centralized configuration to all # microservices. Being a Discovery First Bootstrap configuration, it'll @@ -98,28 +94,20 @@ services: image: geoservercloud/geoserver-cloud-config:1.8.12 user: 1000:1000 # set the userid:groupid the container runs as environment: - # Either 'git' or 'native'. Use the default sample git repository to download the services configuration from - # If 'git', BEWARE config server will look for a branch called "master", and github changed the default branch name to "main" - # For more information, see https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_git_backend - SPRING_PROFILES_ACTIVE: git - # 'git' profile config - CONFIG_GIT_URI: https://github.com/geoserver/geoserver-cloud-config.git - # get the config for this release from the v1.8.12 tag - SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL: master - # where to store the cloned repository, if unset, it'll use /tmp/config-repo- - CONFIG_GIT_BASEDIR: /tmp/git_config - # 'native' profile config - CONFIG_NATIVE_PATH: /tmp/config - # avoid stack trace due to jgit not being able of creating a .config dir at $HOME - XDG_CONFIG_HOME: /tmp + # default to `native` loading the config embedded in /etc/geoserver + # use `git` to fetch the config from a git reposiroty, and CONFIG_GIT_URI to change + # the default repository https://github.com/geoserver/geoserver-cloud-config.git + SPRING_PROFILES_ACTIVE: native + # If using the `git` profile, get the config from this tag + SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL: v1.8.12 # Uncoment to bind to a local filesystem directory if using the 'native' profile #volumes: - # - ./config:/tmp/config + # - ./config:/etc/geoserver deploy: resources: limits: cpus: '2.0' - memory: 512M + memory: 256M # Application facade, provides a single entry point routing to all # microservices (e.g. http://localhost:9090/geoserver/wms, http://localhost:9090/geoserver/wfs, etc) diff --git a/docs/develop/index.md b/docs/develop/index.md index 9212eddd0..13fcfb4d6 100644 --- a/docs/develop/index.md +++ b/docs/develop/index.md @@ -230,7 +230,7 @@ The "local" spring profile in each `config/.yml` file sets a different * `restconfig-v1`: [9105](http://localhost:9105) * `web-ui`: [9106](http://localhost:9106) -At startup time, as configured in its `src/main/resources/bootstrap.yml` file, the service will contact the `discovery-service` at the default `http://localhost:8761/eureka` location, given there's no `eureka.server.url` configuration property set (which is otherwise provided by `docker-compose.yml`). -Since `docker-compose.yml` exposes the `discovery-service` at the local port `8761`, that's all the service being run locally needs to engage in the cluster. The discovery service will provide it with the location of any other service it needs to contact, starting with the `config-service`, where it will ultimatelly get the rest of the application configuration from. +At startup time, as configured in its `src/main/resources/bootstrap.yml` file, the service will contact the `discovery-service` at the default `http://localhost:8761/eureka` location, given there's no `eureka.server.url` configuration property set (which is otherwise provided by `compose.yml`). +Since `compose.yml` exposes the `discovery-service` at the local port `8761`, that's all the service being run locally needs to engage in the cluster. The discovery service will provide it with the location of any other service it needs to contact, starting with the `config-service`, where it will ultimatelly get the rest of the application configuration from. diff --git a/src/apps/infrastructure/config/Dockerfile b/src/apps/infrastructure/config/Dockerfile index 96538ff7d..6a5fadd53 100644 --- a/src/apps/infrastructure/config/Dockerfile +++ b/src/apps/infrastructure/config/Dockerfile @@ -20,6 +20,20 @@ COPY --from=builder spring-boot-loader/ ./ RUN true COPY --from=builder application/ ./ -# Where jgit will try to create a .config directory -ENV XDG_CONFIG_HOME=/tmp +# Either 'git' or 'native'. +ENV SPRING_PROFILES_ACTIVE=native +# 'native' profile config, use the default config embedded in the Docker image. +# Feel free to override with a mounted volume +ENV CONFIG_NATIVE_PATH=/etc/geoserver + +# Config for the 'git' profile +# Uses the default sample git repository to download the services configuration from +ENV CONFIG_GIT_URI: https://github.com/geoserver/geoserver-cloud-config.git +# Override to get the config from the appropriate release TAG or branch +ENV SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL: master +# where to store the cloned repository, if unset, it'll use /tmp/config-repo- +ENV CONFIG_GIT_BASEDIR: /tmp/git_config +# avoid stack trace due to jgit not being able of creating a .config dir at $HOME +ENV XDG_CONFIG_HOME: /tmp +