Setting up Spring Cloud Gateway
Setting up Spring Cloud Gateway as an edge server is straightforward and can be done with the following steps:
- Create a Spring Boot project using Spring Initializr as described in Chapter 3, Creating a Set of Cooperating Microservices – refer to the Using Spring Initializr to generate skeleton code section.
- Add a dependency on
spring-cloud-starter-gateway. - To be able to locate microservice instances through Netflix Eureka, also add the
spring-cloud-starter-netflix-eureka-clientdependency. - Add the edge server project to the common build file,
settings.gradle:
include ':spring-cloud:gateway'
- Add a
Dockerfilewith the same content as for the microservices; seeDockerfilecontent in the folder$BOOK_HOME/Chapter10/microservices. - Add the edge server to our three Docker Compose files:
gateway:
environment:
- SPRING_PROFILES_ACTIVE=docker
build: spring-cloud/gateway
mem_limit: 512m
ports:
- "8080:8080"
From the...