this is done company task for devops.
it supposed to be a cluster with two API and mongo as a database.
there is a traefik for reverse proxy
At the first i have a domain named freetogo.site
that below subdomains have been set in cloudflare
- traefilk.freetogo.site
- acc.freetogo.site
- auth.freetogo.site
- swarm.freetogo.site
And threre is two VPS in ArvanCloud.
There is a Dockerfile in for build
FROM node:latest
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 5000
CMD ["npm" , "start" ]
- https://acc.freetogo.site/accountico/heartbeat
- https://acc.freetogo.site/accountico/profile
- https://acc.freetogo.site/accountico/wallet
- https://acc.freetogo.site/accountico/transacti
- https://acc.freetogo.site/accountico/pay
There is a Dockerfile in for build
FROM node:latest
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 2000
CMD ["npm", "start"]
- https://auth.freetogo.site/authentiq/v1/heartbeat
- https://auth.freetogo.site/authentiq/v1/validate/token
- https://auth.freetogo.site/authentiq/v1/user/list
- https://auth.freetogo.site/authentiq/v1/user/role
- https://auth.freetogo.site/authentiq/v1/user/logout
I use traefik as reverse proxy and manage requests . also i sat a SSL for that to improve security
- --certificatesresolvers.leresolver.acme.caserver=https://acme-v02.api.letsencrypt.org/directory
- --certificatesresolvers.leresolver.acme.email=zibaei.amirhossein@gmai.com
- --certificatesresolvers.leresolver.acme.storage=/le/acme.json
- --certificatesresolvers.leresolver.acme.tlschallenge=true
I use yandu/visualizer for monitoring cluster's status.
you have to create a overlay docker network
docker network create --driver overlay --scope swarm stacktest
in this case i have two node in swarm names C1 and C1
add labels for manager and worker
docker node update --label-add role=base c1
docker node update --label-add role=api c2
run in swarm manager node
docker stack deploy -c docker-stack.yml test
docker stack deploy -c visualizer.stack.yml test