Hello,
I’m developing an application in node.js for backend api and Angular.js for the frontend.
I want that application to be easy to install for “non-tech” users computer so I use Docker to distribute it, so they just have to do docker-compose up/start/stop
.
But I also want to propose it in a online demo, so I’m trying Rancher to orchestrate that
So I’m running one node.js container to run my API service, and one nginx container to serve my angular.js static files.
My docker-compose.yml
looks like this:
services:
backend:
image: myapi:latest
frontend:
image: myfrontend:latest
links:
- backend:backend
labels:
traefik.frontend.rule: 'Host: demo.mydomain.org'
traefik.port: '80'
traefik.enable: 'true'
And I’m setting a proxy_pass
directive in nginx config to serve the backend API on the location https://demo.mydomain.org/api/
:
server {
listen 80;
server_name localhost;
location / {
root /app;
index index.html index.htm;
}
location /api/ {
proxy_pass http://backend:1234/
}
}
This is working great with a standalone docker with docker-compose
.
My problem is that when I’m doing an upgrade in Rancher to change settings on the backend container, the IP address change, and the nginx is still running with old proxy_pass
config, so I have a “Bad Gateway” issue.
I need to manually restart frontend after a backend upgrade.
I thought of different solutions, but as I’m a beginner in Docker and Rancher, I would like to know your valuable opinion
So what do you do when you’re facing similars problems ? What would be a good practice ?
- Put frontend as a backend’s sidekick to upgrade it in the same time ?
- Add a traefik label to the backend with a priority to serve it directly with traefik ?
- Not use nginx for that ?
- Do specific code in frontend to check changes in rancher metadata ?
- Check “Reuse IP address …” in container config ?
- any other idea ?
Thanks a lot if you read my topic! an thanks more if you want to answer me
Congrats for all your work on Rancher, it’s very cool!
Regards,