Skip to content

Instantly share code, notes, and snippets.

@molinto
Created September 17, 2015 12:38
Show Gist options
  • Save molinto/b64ff441f29469fe863f to your computer and use it in GitHub Desktop.
Save molinto/b64ff441f29469fe863f to your computer and use it in GitHub Desktop.
Microservices nodejs
## from example: https://github.com/ibmjstart/Microservices/tree/split ##
productapi:
build: ./services/productAPI
ports:
- "49760:8080"
cartapi:
build: ./services/cartAPI
ports:
- "49761:8080"
reviewapi:
build: ./services/reviewsAPI
ports:
- "49762:8080"
storeclient:
build: .
ports:
- "49763:8080"
@vegasbrianc
Copy link

I'm not sure which service you would like to Load Balance. But you just need to expose port 5000 to the LB and add the LB section to your yml file. Hope this helps

storeclient:
  build: .
  ports:
    - "49763:8080"
  expose:
   - "5000"
lb:
  image: tutum/haproxy
  links:
   - storeclient
  ports:
   - "80:80"
  environment:
   - BACKEND_PORT=5000
   - BALANCE=roundrobin

@molinto
Copy link
Author

molinto commented Sep 18, 2015

Working!!

storeclient:
  build: .
  ports:
    - "80:8080"

productapi:
  build: ./services/productAPI
  ports:
    - "8080"

cartapi:
  build: ./services/cartAPI
  ports:
    - "8080"

reviewapi:
  build: ./services/reviewsAPI
  ports:
    - "8080"

######################################################
## PRODUCT PROXY
######################################################
product-proxy:
  image: tutum/haproxy
  links:
   - productapi
  ports:
   - "7070:80"
  environment:
   - BACKEND_PORT=5000
   - BALANCE=roundrobin


######################################################
## CART PROXY
######################################################
cart-proxy:
  image: tutum/haproxy
  links:
   - cartapi
  ports:
  - "7080:80"
  environment:
   - BACKEND_PORT=5000
   - BALANCE=roundrobin


######################################################
## REVIEW PROXY
######################################################
review-proxy:
  image: tutum/haproxy
  links:
   - reviewapi
  ports:
  - "7090:80"
  environment:
   - BACKEND_PORT=5000
   - BALANCE=roundrobin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment