Skip to content

Commit

Permalink
Added load balancing via Nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
MecuSorin committed Aug 12, 2016
1 parent 52ce85b commit 1d60e62
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
35 changes: 32 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
version: '2'
services:
web:
build: .
webtodel1:
container_name: todel1
image: todel
ports:
- "5000:5000"
- "5000"
volumes:
- .:/go/src/github.com/mecusorin/SampleGoRedisDockerNginx/main
depends_on:
- redis
webtodel2:
container_name: todel2
image: todel
ports:
- "5000"
volumes:
- .:/go/src/github.com/mecusorin/SampleGoRedisDockerNginx/main
depends_on:
- redis
webtodel3:
container_name: todel3
image: todel
ports:
- "5000"
volumes:
- .:/go/src/github.com/mecusorin/SampleGoRedisDockerNginx/main
depends_on:
- redis
redis:
image: redis
loadbalancer:
container_name: todelLoadBalancer
image: loadbalancer-nginx
ports:
- "5000:80"
links:
- "webtodel1"
- "webtodel2"
- "webtodel3"

2 changes: 2 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx:1.10
COPY ./nginx.conf /etc/nginx/nginx.conf
19 changes: 19 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
http {
upstream mygoapp {
server todel1:5000;
server todel2:5000;
server todel3:5000;
}

server {
listen 80;

location / {
proxy_pass http://mygoapp;
}
}
}

worker_processes 4;

events { worker_connections 1024; }
1 change: 1 addition & 0 deletions run_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ then
docker rm $(docker ps -qaf "since=tensorflow-udacity")
docker rmi $(docker images -qf "since=composetest_web")
docker build -t todel --rm .
docker build -t loadbalancer-nginx --rm nginx/
docker-compose up
else
echo "Take care you can delete docker images and containers"
Expand Down

0 comments on commit 1d60e62

Please sign in to comment.