# ============================================================================= # Docker Compose - Electricity Trading Microservices # ============================================================================= # Services: # - gateway: WebSocket/REST API, Auth, Price generation (port 8080) # - order-service: Order processing and persistence (port 8081) # - mock-m7: Trading engine simulation (port 8082) # - rabbitmq: Message broker (ports 5672, 15672) # - postgres: Database (port 5432) # # Quick start (run from project root): # docker-compose -f docker/docker-compose.yml up -d # docker-compose -f docker/docker-compose.yml logs -f gateway # docker-compose -f docker/docker-compose.yml down # ============================================================================= services: # --------------------------------------------------------------------------- # PostgreSQL Database # --------------------------------------------------------------------------- # Stores users (Gateway) and orders (Order Service) postgres: image: postgres:16-alpine container_name: trading-postgres environment: POSTGRES_DB: trading POSTGRES_USER: trading POSTGRES_PASSWORD: trading ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U trading -d trading"] interval: 10s timeout: 5s retries: 5 networks: - trading-network # --------------------------------------------------------------------------- # RabbitMQ Message Broker # --------------------------------------------------------------------------- # Routes messages between services # Management UI: http://localhost:15672 (guest/guest) rabbitmq: image: rabbitmq:3-management-alpine container_name: trading-rabbitmq environment: RABBITMQ_DEFAULT_USER: guest RABBITMQ_DEFAULT_PASS: guest ports: - "5672:5672" # AMQP - "15672:15672" # Management UI volumes: - rabbitmq_data:/var/lib/rabbitmq healthcheck: test: ["CMD", "rabbitmq-diagnostics", "check_running"] interval: 10s timeout: 5s retries: 5 networks: - trading-network # --------------------------------------------------------------------------- # Gateway Service # --------------------------------------------------------------------------- # Entry point: WebSocket, REST API, Auth, Price generation # Publishes orders to Order Service, receives status updates gateway: build: context: .. dockerfile: gateway-service/Dockerfile container_name: trading-gateway environment: SPRING_PROFILES_ACTIVE: docker SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/trading SPRING_DATASOURCE_USERNAME: trading SPRING_DATASOURCE_PASSWORD: trading SPRING_RABBITMQ_HOST: rabbitmq ports: - "8080:8080" depends_on: postgres: condition: service_healthy rabbitmq: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - trading-network restart: on-failure # --------------------------------------------------------------------------- # Order Service # --------------------------------------------------------------------------- # Processes orders, persists to database, communicates with Mock M7 order-service: build: context: .. dockerfile: order-service/Dockerfile container_name: trading-order-service environment: SPRING_PROFILES_ACTIVE: docker SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/trading SPRING_DATASOURCE_USERNAME: trading SPRING_DATASOURCE_PASSWORD: trading SPRING_RABBITMQ_HOST: rabbitmq ports: - "8081:8081" depends_on: postgres: condition: service_healthy rabbitmq: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8081/actuator/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - trading-network restart: on-failure # --------------------------------------------------------------------------- # Mock M7 Service # --------------------------------------------------------------------------- # Simulates EPEX SPOT trading engine # Receives orders, sends ACK immediately, FILL/REJECT after delay mock-m7: build: context: .. dockerfile: mock-m7-service/Dockerfile container_name: trading-mock-m7 environment: SPRING_PROFILES_ACTIVE: docker SPRING_RABBITMQ_HOST: rabbitmq ports: - "8082:8082" depends_on: rabbitmq: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8082/actuator/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - trading-network restart: on-failure networks: trading-network: driver: bridge volumes: postgres_data: rabbitmq_data: