Skip to content

ecomera-ecosystem/ecomera-config-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecomera Config Server

Java Spring Boot Spring Cloud License

Centralized configuration management for the Ecomera microservices ecosystem using Spring Cloud Config Server.


📋 Overview

Provides externalized configuration for all Ecomera microservices across different environments (dev, staging, production). Configurations are stored in src/main/resources/config/ and served via REST API.


🛠️ Tech Stack

  • Spring Boot 3.5.11
  • Spring Cloud Config Server 2025.0.1
  • Native Profile - File-based configuration storage
  • Eureka Client - Service registration

🚀 Running Locally

Prerequisites

  • Java 17+
  • Maven 3.6+
  • Eureka Server running on port 8761

Start the Server

mvn spring-boot:run

Config server available at: http://localhost:8888

Eureka dashboard: http://localhost:8761 (should show ECOMERA-CONFIG-SERVER)


⚙️ Configuration

Server Properties

Property Default Description
server.port 8888 Config server port
spring.profiles.active native Configuration source (native = classpath files)
eureka.client.service-url.defaultZone http://localhost:8761/eureka/ Eureka server URL

📂 Configuration Files Structure

src/main/resources/
├── application.yml                          # Shared across all services
└── config/
    ├── ecomera-eureka-service-registry.yml      # Eureka-specific config
    ├── auth-service.yml                         # Auth Service config
    └── *-service.yml                            # Other service configs

File Naming Convention

Config files follow pattern: {spring.application.name}.yml

Example: Service with spring.application.name=auth-service fetches auth-service.yml


🔌 Client Usage

Microservices fetch configuration by adding to their application.yml:

spring:
  application:
    name: auth-service  # Matches auth-service.yml
  config:
    import: optional:configserver:http://localhost:8888

On startup:

  1. Service connects to Config Server
  2. Fetches application.yml (shared config)
  3. Fetches auth-service.yml (service-specific config)
  4. Merges both configurations

🧪 Testing Configuration

Verify Config Server is Running

curl http://localhost:8888/actuator/health

Fetch Configuration for a Service

# Get auth-service configuration
curl http://localhost:8888/auth-service/default

# Get eureka configuration
curl http://localhost:8888/ecomera-eureka-service-registry/default

Response: JSON with merged configuration properties


🐳 Docker Support

Build Image

docker build -t ecomera-config-server .

Run Container

docker run -p 8888:8888 \
  -e EUREKA_SERVER_URL=http://eureka:8761/eureka/ \
  ecomera-config-server

📊 Endpoints

Endpoint Description
/{application}/{profile} Get configuration for service
/actuator/health Health check
/actuator/info Service information

Example:

  • http://localhost:8888/auth-service/default
  • http://localhost:8888/auth-service/dev
  • http://localhost:8888/auth-service/prod

🔗 Related Services


🏗️ Architecture

Microservices → Config Server (port 8888) → classpath:/config/*.yml
                      ↓
                Eureka Server (port 8761)

All services fetch their configuration from Config Server on startup and register with Eureka for service discovery.


📝 Adding New Service Configuration

  1. Create {service-name}.yml in src/main/resources/config/
  2. Add service-specific properties
  3. Restart Config Server (or use @RefreshScope for runtime updates)
  4. Service will fetch config on next startup

📄 License

MIT License - see LICENSE file for details


About

Spring Cloud Config Server providing centralized configuration management for microservices, integrated with HashiCorp Vault for secure secret management in the Ecomera ecosystem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors