Skip to content

justedlev/bridgewayhub

Repository files navigation

BridgeWay Hub

🧱 API Gateway

language framework Docker Image Version license stars issues

📋 About

BridgeWay Hub example implementation of API Gateway based on Spring Boot 3, Keycloak as a security layer and Eureka Client as service registry, in microservice architecture, detailed configuration will depend directly on additional business requirements and is applied in the application properties. For more details

⚠️ Requirements

Before running the app you need to configure the next services that depends on:

  • Keycloak - security layer
  • DB for Keycloak optional
  • Eureka Server, my solution optional

▶️ Run

Intellij

Clone the repository using git clone https://github.com/Justedlev/bridgewayhub.git and after that run the app local, you can use the simple run configuration, that based on .env and jvm options, make sure that the service registry (eureka service) already started.

Note

The Service Registry (Discovery Service) can be disabled by using the properties if needed

spring:
  cloud:
    discovery:
      enabled: false
eureka:
  client:
    enabled: false

Tip

You can also disable it in .vmoptions, just adding the envs

-Dspring.cloud.discovery.enabled=false
-Deureka.client.enabled=false

🐳 Docker

I have a repository on Docker Hub

📝 Docker compose

Simple command to run the container:

docker compose up -d --build

Learn More with Docker CLI: Compose

The full compose.yaml that I personally use

name: justedlev-msrv
services:
  bridgewayhub:
    container_name: bridgewayhub
    image: justedlev/bridgewayhub:latest
    build:
      context: docs
    env_file:
      - .env
    ports:
      - "8765:${SERVER_PORT}"
    depends_on:
      - sso
      - service-registry

  # Service discovery
  service-registry:
    container_name: service-registry
    image: justedlev/simple-eureka-server:latest
    environment:
      SERVER_PORT: 8761
      EUREKA_INSTANCE_HOSTNAME: service-registry
      SPRING_SECURITY_USER_NAME: example
      SPRING_SECURITY_USER_PASSWORD: example
    ports:
      - "8761:${SERVER_PORT}"

  # SSO service (keycloak)
  sso:
    container_name: keycloak
    image: quay.io/keycloak/keycloak:25.0.6
    command: [ "start-dev" ]
    environment:
      KEYCLOAK_ADMIN: "{example}"
      KEYCLOAK_ADMIN_PASSWORD: "{example}"
      KC_HEALTH_ENABLED: true
      KC_HOSTNAME: localhost
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres:5432/{example}
      KC_DB_USERNAME: "{example}"
      KC_DB_PASSWORD: "{example}"
      KC_DB_SCHEMA: keycloak
    depends_on:
      - postgres
    ports:
      - "9321:8080"

  # Postgres DB
  postgres:
    container_name: postgres
    image: postgres:16.4-alpine
    environment:
      POSTGRES_DB: "{example}"
      POSTGRES_USER: "{example}"
      POSTGRES_PASSWORD: "{example}"
    volumes:
      - db-data:/var/lib/postgresql/data
      - /.db:/docker-entrypoint-initdb.d
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d" ]
      interval: 15s
      timeout: 10s
      retries: 5
      start_period: 12s
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: 250MB

volumes:
  db-data: