Skip to main content

Overview

While we previously ran the discovery-service and api-gateway as standalone applications from the IDE or JAR files, we can also run them through Docker containers. This guide explains how to run all Linqra components using Docker.

Docker Compose Configuration

The docker-compose.yml file includes all necessary services:
  • Infrastructure Services:
    • PostgreSQL (for Keycloak)
    • pgAdmin (PostgreSQL management)
    • Keycloak (authentication)
    • MongoDB (replica set with 3 nodes)
    • Redis (rate limiting and caching)
  • Core Services:
    • Discovery Server (Eureka)
    • API Gateway with HAProxy Load Balancer

Certificate Preparation

Before running the services, ensure you have the necessary certificates prepared for HAProxy:
The final directory structure should look like this:
These certificates should have been generated during the initial setup. This section shows how they were created for reference.

Running Core Services

To start all core services with Docker Compose:
Here it is how it looks like:
Linqra Core Service Instances
This command:
  • Uses the local Docker Compose installation
  • Specifies the compose file location
  • Sets the project name to ‘linqra’
  • Runs in detached mode (-d)
  • Builds images if needed (—build)

Rebuilding Individual Services

If you update the api-gateway code or configuration, you can rebuild just that service:

Service Configuration

Discovery Server (Eureka)

Load Balancer and API Gateway

The API Gateway service is configured with 3 replicas for high availability, with HAProxy load balancing requests across these instances through port 7777.

Complete Docker Compose Configuration

Below is the complete docker-compose.yml file for local deployment:
This configuration is specifically designed for local development and testing. The services are configured to run on localhost with appropriate port mappings and network settings.

Client Services

After setting up the core infrastructure and gateway services, you can deploy the example client services. Each service is configured to run with multiple instances for high availability.

Product Service

The product service uses its own Docker configuration and certificates:
To deploy the product service:
This will create three instances of the product service:
  • linqra_product_service-product-service-1
  • linqra_product_service-product-service-2
  • linqra_product_service-product-service-3
Product Service Docker Instances

Inventory Service

Similar to the product service, the inventory service has its own Docker configuration:
To deploy the inventory service:
This will create three instances of the inventory service:
  • linqra_inventory_service-inventory-service-1
  • linqra_inventory_service-inventory-service-2
  • linqra_inventory_service-inventory-service-3
Inventory Service Docker Instances
Both services use their own SSL certificates:
  • Product Service: product-keystore-container.jks and client-truststore.jks
  • Inventory Service: inventory-keystore-container.jks and client-truststore.jks
The certificates are mounted into the containers and used for secure communication with other services.

Service Architecture

Each client service:
  • Runs with 3 replicas for high availability
  • Uses SSL for secure communication
  • Registers with Eureka discovery service
  • Communicates through the API Gateway
  • Authenticates via Keycloak
  • Shares the same Docker network (linqra-network) with core services