Skip to content
Snippets Groups Projects
Commit 7ec513fc authored by Yehor Potebenko's avatar Yehor Potebenko
Browse files

feat: divide the backend on 2 instances, run first instance on 3000port,...

feat: divide the backend on 2 instances, run first instance on 3000port, second one on 3001port, add loadbalancer
parent 4c2bbc14
No related branches found
No related tags found
No related merge requests found
server {
listen 3000;
location / {
proxy_pass http://backend:3000;
}
}
\ No newline at end of file
version: '3' version: '3.2'
services: services:
frontend: frontend:
...@@ -13,19 +13,31 @@ services: ...@@ -13,19 +13,31 @@ services:
stdin_open: true stdin_open: true
tty: true tty: true
depends_on: depends_on:
- backend - loadbalancer
networks: networks:
- letsDo-network - letsDo-network
backend: backend1:
build:
context: server
dockerfile: Dockerfile
env_file:
- .env
restart: always
depends_on:
- database
environment:
- DB_USER
- DB_PASSWORD
networks:
- letsDo-network
backend2:
build: build:
context: server context: server
dockerfile: Dockerfile dockerfile: Dockerfile
env_file: env_file:
- .env - .env
# container_name: node-server
# ports:
# - '${BACKEND_PORT}:${BACKEND_PORT}'
restart: always restart: always
depends_on: depends_on:
- database - database
...@@ -39,12 +51,13 @@ services: ...@@ -39,12 +51,13 @@ services:
image: mongo image: mongo
container_name: mongo-db container_name: mongo-db
nginx: loadbalancer:
image: nginx:latest build:
volumes: context: loadbalancer
- ./conf.d:/etc/nginx/conf.d dockerfile: Dockerfile
depends_on: links:
- backend - backend1
- backend2
ports: ports:
- ${BACKEND_PORT}:${BACKEND_PORT} - ${BACKEND_PORT}:${BACKEND_PORT}
networks: networks:
......
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
http {
upstream backend {
server backend1:3000;
server backend2:3001;
}
server {
listen 3000;
location / {
proxy_pass http://backend/;
}
}
}
events {}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment