Skip to content

Commit

Permalink
Add ready to use docker composition
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Feb 16, 2021
1 parent aab9eb0 commit 979e5ed
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 11 deletions.
10 changes: 3 additions & 7 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Centralized microservices configuration
# Cloud Native GeoServer Externalized configuration sample repository

This directory contains the spring configuration properties or yaml files for all
GeoServer microservices, as used by the config-service, following
This repository contains sample/default spring configuration files for all
micro-services in the [Cloud Native GeoServer](https://github.com/camptocamp/geoserver-microservices) project, as used by the `config-service`, following
[spring-cloud-config](https://cloud.spring.io/spring-cloud-config/reference/html/) guidelines.

The contents of this directory are copied to the `config-service`'s `.jar` file at build time,
so they're accessible as classpath resources. Nonetheless, it's advisable to not use classpath
configuration, and hence the default docker composition at the project's root directory sets
this directory up as a bound volume to the `config-service` container(s).
4 changes: 3 additions & 1 deletion config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ management:
endpoint:
shutdown.enabled: true
info.enabled: true
health.enabled: true
health:
enabled: true
show-details: always
endpoints:
enabled-by-default: true
web.exposure.include: "*"
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ services:
EUREKA_SERVER_URL: ${EUREKA_SERVER_URL}
JAVA_OPTS: ${CONFIG_JAVA_OPTS}
RABBITMQ_HOST: rabbitmq
CONFIG_PATH: /opt/app/config
# 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: native
# 'git' profile config
CONFIG_GIT_URI: https://github.com/groldan/geoserver-microservices-config
CONFIG_GIT_BASEDIR: /opt/app/git_config
# 'native' profile config
CONFIG_NATIVE_PATH: /opt/app/config
networks:
- gs-cloud-network
volumes:
Expand Down
209 changes: 209 additions & 0 deletions docs/deploy/docker-compose/stable/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
version: "3.8"
# This docker composition can be used as a quick start. Docker images will be fetch from docker hub's
# couldnativegeoserver organization. The config-service is set up to use a public remote git repository. At start up, it'll
# clone it to the service instance container's filesystem and serve application configurations from there.
#
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

networks:
gs-cloud-network:
driver: bridge

services:
rabbitmq:
image: rabbitmq:3-management
restart: always
environment:
RABBITMQ_DEFAULT_USER: "guest"
RABBITMQ_DEFAULT_PASS: "guest"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
networks:
- gs-cloud-network
ports:
- "5672:5672"
- "15672:15672"

database:
image: cloudnativegeoserver/gs-cloud-database:0.2.0
environment:
POSTGRES_DB: "geoserver_config"
POSTGRES_USER: "geoserver"
POSTGRES_PASSWORD: "geo5erver"
ports:
- 5432:5432
networks:
- gs-cloud-network
volumes:
- postgresql_config_data:/var/lib/postgresql/data

# 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: cloudnativegeoserver/gs-cloud-discovery-service:0.2.0
environment:
SERVER_PORT: 8761
EUREKA_INSTANCE_HOSTNAME: discovery
JAVA_OPTS: -Xmx128m -XX:ActiveProcessorCount=2
ports:
- 8761:8761 # for development, so services can be run from localhost and find the discovery service running on docker
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "-m", "1", "http://localhost:8761/actuator/health"]
interval: 1s
timeout: 1s
retries: 15

# Spring Cloud Config service, provides centralized configuration to all
# microservices. Being a Discovery First Bootstrap configuration, it'll
# register itself with the Eureka discovery service and can be scaled
config:
image: cloudnativegeoserver/gs-cloud-config-service:0.2.0
depends_on:
- discovery
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
management_endpoint_health_show-details: always # never|always|when-authorized
# 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/groldan/geoserver-microservices-config
CONFIG_GIT_BASEDIR: /opt/app/git_config
# 'native' profile config
CONFIG_NATIVE_PATH: /opt/app/config
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "-m", "1", "http://localhost:8080/actuator/health"]
interval: 1s
timeout: 1s
retries: 30
# wait until discovery service is available
command: dockerize -wait http://discovery:8761/actuator/health --timeout 15s java -Xmx128m -jar /opt/app/config-service.jar

# Application facade, provides a single entry point routing to all
# microservices (e.g. http://localhost:9090/geoserver/wms, http://localhost:9090/geoserver/wfs, etc)
gateway:
image: cloudnativegeoserver/gs-cloud-gateway:0.2.0
depends_on:
- discovery
- config
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
ports:
- 9090:8080
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
# wait until config service is available
command: dockerize -wait http://config:8080/gateway-service/default --timeout 60s java -Xmx128m -jar /opt/app/gateway-service.jar

# catalog microservice, provides a unified catalog backend to all services
catalog:
image: cloudnativegeoserver/gs-cloud-catalog:0.2.0
depends_on:
- discovery
- config
- database
- rabbitmq
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
JDBCCONFIG_URL: "jdbc:postgresql://database:5432/geoserver_config"
JDBCCONFIG_USERNAME: "geoserver"
JDBCCONFIG_PASSWORD: "geo5erver"
spring_cloud_config_fail-fast: "false"
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
command: dockerize -wait http://config:8080/catalog-service/default --timeout 60s java -Xmx256m -XX:ActiveProcessorCount=2 -jar /opt/app/catalog-service.jar

# WFS microservice, port dynamically allocated to allow scaling (e.g docker-compose scale wfs=5)
wfs:
image: cloudnativegeoserver/gs-cloud-wfs:0.2.0
depends_on:
- rabbitmq
- catalog
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
command: dockerize --timeout 60s -wait http://config:8080/wfs-service/default -wait http://catalog:8080/actuator/health java -Xmx256m -XX:ActiveProcessorCount=2 -jar /opt/app/wfs-service.jar

# WMS microservice, port dynamically allocated to allow scaling (e.g docker-compose scale wms=5)
wms:
image: cloudnativegeoserver/gs-cloud-wms:0.2.0
depends_on:
- rabbitmq
- catalog
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
# wait until config service is available
command: dockerize -wait http://config:8080/wms-service/default -wait http://catalog:8080/actuator/health --timeout 60s java -Xmx1G -XX:ActiveProcessorCount=2 -jar /opt/app/wms-service.jar

# WCS microservice, port dynamically allocated to allow scaling (e.g docker-compose scale wcs=5)
wcs:
image: cloudnativegeoserver/gs-cloud-wcs:0.2.0
depends_on:
- rabbitmq
- catalog
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
# wait until config service is available
command: dockerize -wait http://config:8080/wcs-service/default -wait http://catalog:8080/actuator/health --timeout 60s java -Xmx1G -XX:ActiveProcessorCount=2 -jar /opt/app/wcs-service.jar

# REST config microservice, port dynamically allocated to allow scaling (e.g docker-compose scale rest=5)
rest:
image: cloudnativegeoserver/gs-cloud-restconfig-v1:0.2.0
depends_on:
- rabbitmq
- catalog
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
# wait until config service is available
command: dockerize -wait http://config:8080/restconfig-service/default -wait http://catalog:8080/actuator/health --timeout 60s java -Xmx256m -XX:ActiveProcessorCount=2 -jar /opt/app/restconfig-service.jar

# WEB UI microservice
webui:
image: cloudnativegeoserver/gs-cloud-web-ui:0.2.0
depends_on:
- rabbitmq
- catalog
environment:
EUREKA_SERVER_URL: http://discovery:8761/eureka
RABBITMQ_HOST: rabbitmq
networks:
- gs-cloud-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
# wait until config service is available
command: dockerize -wait http://config:8080/web-ui/default -wait http://catalog:8080/actuator/health --timeout 60s java -Xmx512m -XX:ActiveProcessorCount=2 -jar /opt/app/web-ui-service.jar

18 changes: 16 additions & 2 deletions support-services/config/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ server:
spring:
main.banner-mode: off
application.name: config-service
profiles.active: native #use native filesystem config by default instead of git. REVISIT.
profiles.active: native #use native filesystem config by default instead of git.
cloud.loadbalancer.ribbon.enabled: false # ribbon is in maintenance mode and should be replaced by spring-cloud-loadbalancer
#config.server.native.searchLocations: ${config.path:file:./config}
cloud:
config.server: # see https://cloud.spring.io/spring-cloud-config/reference/html/#_spring_cloud_config_server
git:
uri: ${config.git.uri}
skipSslValidation: true
timeout: 10
refreshRate: 30 # Default value of 0 makes the git backend fetch updated configuration from the Git repo every time it is requested
basedir: ${config.git.basedir:./git_config} # where to store the cloned repository, if unset, it'll use /tmp/config-repo-<randomid>
native:
searchLocations: ${config.native.path:file:./config}

eureka:
instance:
Expand All @@ -25,3 +34,8 @@ eureka:
defaultZone: ${eureka.server.url:http://localhost:8761/eureka}
healthcheck:
enabled: false

logging:
level:
# Avoid log flooding with "INFO Adding property source: file:<...>/application.yml" triggered by the actuator health check
org.springframework.cloud.config.server.environment.NativeEnvironmentRepository: WARN

0 comments on commit 979e5ed

Please sign in to comment.