ultimate-backend icon indicating copy to clipboard operation
ultimate-backend copied to clipboard

Consul configration with docker-compose

Open murtaza-khan opened this issue 5 years ago • 5 comments

@juicycleff hi,

I have just cloned this Repo and creating a build with docker-compose for accounts service with the consul and trying to run. But I am facing an issue with the accounts service for the consul setting kv.get. image

I have tried both methods. 1- Setting up the consul manually before running the command docker-compose for a build. 2- And configuration consul in the docker-compose-dev.yaml file.

Butt I am facing the same issue key-value Error: consul: kv.get: connect ECONNREFUSED 127.0.0.1:8500 I am pasting my docker-compose.dev.ymal configuration.

version: "3.2"

services:
  service-account:
    build:
      context: .
      dockerfile: apps/service-account/Dockerfile
      args:
        NODE_ENV: development
    image: "service-account:latest"
    restart: always
    depends_on:
      - consul
      - redis
    environment:
      - CONSUL_HOST=consul
      - NATS_HOST=nats
      - DISCOVERY_HOST=localhost
    ports:
      - 50054:50054
    labels:
      kompose.service.type: clusterip
      kompose.image-pull-secret: "gitlabregcrednew"
      kompose.image-pull-policy: "Always"
   consul:
    container_name: consul
    ports:
      - "8400:8400"
      - "8500:8500"
      - "8600:53/udp"
    image: consul
    command: ["agent", "-server", "-bootstrap", "-ui", "-client", "0.0.0.0"]
    labels:
      kompose.service.type: nodeport
      kompose.service.expose: "true"
      kompose.image-pull-policy: "Always"

  eventstore:
    container_name: eventstore
    ports:
      - "2113:2113"
      - "1113:1113"
    image: eventstore/eventstore:release-5.0.8
    labels:
      kompose.service.type: nodeport
      kompose.service.expose: "true"
      kompose.image-pull-policy: "Always"

  nats:
    container_name: nats
    ports:
      - "4222:4222"
      - "6222:6222"
      - "8222:8222"
    image: nats
    labels:
      kompose.service.type: nodeport
      kompose.service.expose: "true"
      kompose.image-pull-policy: "Always"

  mongo:
    container_name: mongo
    image: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: changeit
    restart: always
    expose:
      - 27017

  redis:
    container_name: redis
    image: redis
    restart: always
    expose:
      - 6379

My config.example

app:
  port: 9900
  auth:
    jwtSettings:
      secret: "eyJhbGciOiJSUzI1NiIsImtpZCI6Im1hYXNfcHJvZF8yMDIwMDMyNiIsInR5cCI6IkpXVCJ9"
  database:
    name: "srv-account"

database:
  mongodb:
    uri: mongodb://localhost:27017/
    name: srv-account
    options: ""

  eventstore:
    poolMax:
    poolMin:
    streamProtocol: "http"
    hostname: "localhost"
    httpPort: 2113
    httpPotocol: "http"
    tcpPassword: "changeit"
    tcpUsername: "admin"
    tcpPort: 1113
    tcpProtocol: tcp

  redis:
    host: "localhost"
    port: "6379"
    password: ""

murtaza-khan avatar Oct 20 '20 07:10 murtaza-khan

@juicycleff any idea on this?

n123456789k avatar Jun 23 '21 22:06 n123456789k

@uncodable I think you should try setting your consul address to 0.0.0.0.

juicycleff avatar Jun 23 '21 22:06 juicycleff

@murtaza-khan where you able to figure this out. I have a similar problem and running Consul local doesn't fix it.

sixtay avatar Jul 15 '21 16:07 sixtay

Fixed the issue by modifying each services bootstrap-development.yml from consul: host: localhost

to consul: host: ${{CONSUL_HOST}}

sixtay avatar Jul 16 '21 14:07 sixtay

please any solution ? I still have the same error @juicycleff @murtaza-khan @sixtay

mohamedazizmasmoudi avatar Oct 22 '22 11:10 mohamedazizmasmoudi