0

I am trying to setup a cloud architecture on aws where there is an rds box that holds wa_db, and seperate instances of master and coreapps running in their own environment. I'm having trouble setting the path to the db (hostname) for wacore to connect to.

My docker-compose looks like this:

version: '3'

volumes:
  whatsappMedia:
    driver: local
  mysqlData:
    driver: local

services:
  db:
    image: mysql:5.7.26
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: testpass
      MYSQL_USER: testuser
      MYSQL_PASSWORD: testpass
    expose:
        - "33060"
    ports:
        - "33060:3306"
    volumes:
     - mysqlData:/var/lib/mysql
    network_mode: bridge
  wacore:
    image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.33.3 docker-compose <command> <options>)}
    command: ["/opt/whatsapp/bin/wait_on_mysql.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
    volumes:
     - whatsappMedia:/usr/local/wamedia
    env_file:
      - db.env
    environment:
      # This is the version of the docker templates being used to run WhatsApp Business API
      WA_RUNNING_ENV_VERSION: v2.2.3
      ORCHESTRATION: DOCKER-COMPOSE
      WA_API_KEY: "sizanani_WA_API_KEY"
    depends_on:
      - "db"
    network_mode: bridge
    links:
      - db
  waweb:
    image: docker.whatsapp.biz/web:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.33.3 docker-compose <command> <options>)}
    command: ["/opt/whatsapp/bin/wait_on_mysql.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
    ports:
     - "9090:443"
    volumes:
     - whatsappMedia:/usr/local/wamedia
    env_file:
      - db.env
    environment:
      WACORE_HOSTNAME: wacore
      # This is the version of the docker templates being used to run WhatsApp Business API
      WA_RUNNING_ENV_VERSION: v2.2.3
      ORCHESTRATION: DOCKER-COMPOSE
    depends_on:
      - "db"
      - "wacore"
    links:
      - db
      - wacore
    network_mode: bridge

i.e the default docker-compose for the dev-single-instance. Found under "installation".

My db.env looks like this.

WA_DB_ENGINE=MYSQL
WA_DB_HOSTNAME=db
WA_DB_PORT=3306
WA_DB_USERNAME=root
WA_DB_PASSWORD=testpass
WA_DB_CONNECTION_IDLE_TIMEOUT=180000

I would like to point WA_DB_HOSTNAME to a remote db, which seems possible according to their setup guide. However, I have tried WA_DB_HOSTNAME=localhost and WA_DB_HOSTNAME=127.0.0.1 to no avail. I have seen Weiyan Wang's answer which mentions that I do not need to access the db directly, however if the db is in a remote location I'd still need to update WA_DB_HOSTNAME.

Minenhle
  • 1
  • 1
  • Are you able to connect to the db from within your docker container using `localhost` or `127.0.0.1`? ie using `docker exec -it ` – Andrew L Apr 29 '21 at 18:20
  • Also are you are of the CloudFormation Templates offered by WhatsApp for spinning up an API instance on AWS? https://developers.facebook.com/docs/whatsapp/aws#whatsapp-setup – Andrew L Apr 29 '21 at 18:21
  • Hi @AndrewL, when I run the docker command: `docker exec -it bash` I can log onto the container and into the MySQL command line using `mysql -u root -p`. I'm currently trying to create a staging environment that uses multiple boxes so I'm not using that CloudFormation documentaion. – Minenhle May 01 '21 at 11:15
  • What happens when you set `WA_DB_HOSTNAME=127.0.0.1` and try to start the containers? Can you check your coreapp logs for DB related errors or warnings on startup https://developers.facebook.com/docs/whatsapp/support-logs – Andrew L May 02 '21 at 16:51
  • The db starts up and I can open it. But when wacore starts up it says it's waiting for the db to start up. But I have decided to use the [CloudFormation Setup](https://developers.facebook.com/docs/whatsapp/aws#whatsapp-setup) you sugessted to achieve what I wanted. And for the single instance I just ran all 3 containers on one box. – Minenhle May 05 '21 at 05:08

0 Answers0