Skip to content

Threenodes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -16,3 +16,6 @@
## Run
- Run command `docker-compose up`
- Access to http://localhost/

## Thanks
https://www.adictosaltrabajo.com/2017/06/22/balanceando-apps-de-spring-boot-con-nginx-en-docker/
52 changes: 37 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
version: '3'
services:
nginx:
container_name: some-nginx
image: nginx:1.13
restart: always
ports:
- 80:80
- 443:443
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- app

app:
build:
dockerfile: ./nginx/nginx.dockerfile
context: .
container_name: my-nginx
image: armandoss/my-nginx
restart: always
ports:
- 80:80
depends_on:
- "app1"
- "app2"
- "app3"
app1:
hostname: app1
restart: always
build: ./app
working_dir: /app
volumes:
- ./app:/app
ports:
- 8081:8081
command: mvn clean spring-boot:run -Drun.jvmArguments='-Dserver.port=8081'
app2:
hostname: app2
restart: always
build: ./app
working_dir: /app
volumes:
- ./app:/app
ports:
- 8082:8082
command: mvn clean spring-boot:run -Drun.jvmArguments='-Dserver.port=8082'
app3:
hostname: app3
restart: always
build: ./app
working_dir: /app
volumes:
- ./app:/app
expose:
- "8080"
command: mvn clean spring-boot:run
ports:
- 8083:8083
command: mvn clean spring-boot:run -Drun.jvmArguments='-Dserver.port=8083'
20 changes: 0 additions & 20 deletions nginx/conf.d/app.conf

This file was deleted.

11 changes: 11 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
upstream my-app {
server 172.17.0.1:8081 weight=1;
server 172.17.0.1:8082 weight=1;
server 172.17.0.1:8083 weight=1;
}

server {
location / {
proxy_pass http://my-app;
}
}
3 changes: 3 additions & 0 deletions nginx/nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY /nginx/nginx.conf /etc/nginx/conf.d/default.conf