I have written an app in angular that relies on a restful middle-ware layer which in turn contacts the business logic layer which manages the data on the database.
The infrastructure is as follows:
- Mysql handles persistence
- Business-logic on Tomcat 8.5.31
- Restful-middle-ware on Tomcat 8.5.31
- Front-end app on nginx 1.15.2 & angular 5
On my workstation everything works beautifully, however, after dockerizing all the services the front-end will not find the middle-ware services. below is my docker-compose.yml file:
version: "3.3" services: ngxseeker: image: bilorge/seekr:ngxseekr-0.01 networks: - pub ports: - 80:80 ckerws: image: bilorge/seekr:seekr-web-0.01 networks: - priv - pub seekr-service: image: bilorge/seekr:seekr-server-0.01 networks: - priv ckerdb: image: mysql:5.7 volumes: - cker-db-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=&*$#$^## deploy: placement: constraints: [node.role == manager] networks: - priv networks: pub: driver: overlay priv: driver: overlay volumes: cker-db-data:
Its worth mentioning in order to make the application compatible to work docker and its services I added the service names to my hosts file on my work station. The entries were as follows:
- 127.0.0.1 ngxseeker
- 127.0.0.1 ckerws
- 127.0.0.1 seekr-service
- 127.0.0.1 ckerdb
this way when I run it locally on my workstation everything will resolve to the same service names inside the docker swarm. Again, all this works when I run it in my IDE or stand alone on my workstation.
Prior to running on swarm I comment the hosts entries to make sure they will not muddy the waters. when I deploy the stack (single node swarm) I wait and make sure all services are up and ready for work.
I then point my browser to 127.0.0.1 and get my app’s landing page which greets me with login page. I provide the credentials and immediately fails. The developer tools indicate the post request goes out, but it never comes back.
I have verified the following:
- Database has data
- The business logic server is able to talk to the database
- the middle ware server is able to resolve the business logic layer
- the front end is able to resolve the middle-ware layer
On the last point I made a reverse proxy entry on ngix to hit the landing page for the Tomcat running the middle-ware layer and its successful. BTW, at boot up if nginx does not find the reverse proxy entries it will not start.
during a trouble shooting session I create a Ubuntu VM (latest) in Virtualbox with a bridged network as I wanted the vm get an ip from my router. I then deployed my stack, single node swarm, except for the front end which I was running from my work station. because the swarm was hosted externally I exposed port 8080 on the ckerws service. I also added a host entry for the vm and the service:
- 192.168.1.62 ckerws
- 192.168.1.62 poky
I fired up browser and pointed it to 127.0.0.1 as usual the landing page loads up, however, this time when I provided the credentials it worked! if I bring in all the service under one swarm then it breaks…
I’m stumped and not sure whats going on… I have a feeling that it has to do we service scope resolution, however, I’m a bit out of my element there.