Pointing CHT Sync at a docker helper instance

Hi there!

I’m running a Docker Helper instace of CHT locally on my laptop. It lives at https://10-0-32-155.local-ip.medicmobile.org:10471/.

I’m trying to follow the steps to set up CHT Sync locally and point it to my Docker Helper instance above.

This is my .env file for sync:

# (Optional) project wide
COMPOSE_PROJECT_NAME=pipeline

# postgresql
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=data
POSTGRES_SCHEMA=v1
POSTGRES_TABLE=medic # for dbt use only
POSTGRES_HOST=someip # Your postgres instance IP or endpoint in "prod".
POSTGRES_PORT=5432

# dbt
DBT_POSTGRES_USER=postgres
DBT_POSTGRES_PASSWORD=postgres
DBT_POSTGRES_SCHEMA=dbt
DBT_POSTGRES_HOST=postgres # Your postgres instance IP or endpoint in "prod".
CHT_PIPELINE_BRANCH_URL="https://github.com/medic/cht-pipeline.git#main"
DATAEMON_INTERVAL=5

# couchdb
COUCHDB_USER=medic
COUCHDB_PASSWORD=password
COUCHDB_DBS="medic" # space separated list of databases you want to sync e.g "medic medic_sentinel"
COUCHDB_HOST=10-0-32-155.local-ip.medicmobile.org
COUCHDB_PORT=10471
COUCHDB_SECURE=true

This is my compose call:

docker-compose -f docker-compose.postgres.yml -f docker-compose.yml up -d

However, the couch2pg container keeps on restarting with this error:

Node.js v20.16.0
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error: getaddrinfo EAI_AGAIN someip
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'someip'
}

I can confirm if I shell into the pgadmin container, for example, I can both ping and wget the 10-0-32-155.local-ip.medicmobile.org URL.

looks like the issue is the postgres database, not couchdb

hostname: 'someip'

it’s set up to allow syncing to an external postgres, but for local development (and with this compose call docker-compose -f docker-compose.postgres.yml -f docker-compose.yml up -d) you probably want a temporary postgres created by docker compose.
so you can set POSTGRES_HOST=postgres to connect to that one.

1 Like

@twier - thanks!

That worked like a charm to set as you suggested:

POSTGRES_HOST=postgres

Now couch2pg is able to resolve the host based on the compose service name of postgres.

I now get an auth error:

error: password authentication failed for user "postgres"

What is the default login for postgres? The .env example defaults to:

POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

Which I assumed would work out of the box, but maybe I need to manually set it?

Huh - I’m not sure what I did wrong the first time! I was able to do a clean install and use these default values in the .env file for login and password successfully:

# postgresql
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

thanks again for the help!

1 Like