Skip to content

Files

Latest commit

May 8, 2020
ac640cb · May 8, 2020

History

History

blog

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 13, 2020
Feb 28, 2018
Jul 22, 2017
Jul 6, 2017
Feb 2, 2020
Feb 28, 2018
Mar 4, 2018
Mar 4, 2018
Feb 2, 2020
Jan 13, 2020
Feb 12, 2020
Feb 2, 2020
Feb 2, 2020
May 8, 2020
May 8, 2020

Blog example

Blog screenshot

🚩 Features

  • multiple services (www, posts, users)
  • Docker files to running in Docker containers (3 architectures)
  • ExpressJS www server with Pug
  • MongoDB database with moleculer-db and moleculer-db-adapter-mongoose modules
  • NATS transporter
  • Redis cacher
  • Traefik reverse proxy (in micro arch)
  • static client side

🔩 Install

git clone https://github.com/moleculerjs/moleculer-examples.git
cd blog

🎲 Start locally

To start locally, you need to running a MongoDB server on localhost.

npm install
npm start

Open the http://localhost:3000/ URL in your browser.

☁️ Start in Docker

🏠 Running as monolith

All services are running in a container.

cd docker/mono
docker-compose up -d --build
# or
# ./start.sh

Open the http://docker-machine:3000/ URL in your browser.

🏢 Running as microservices

All services are running in separated containers, communicate via NATS & use Traefik reverse proxy.

cd docker/micro
docker-compose up -d --build
# or
# ./start.sh

Open the http://docker-machine:3000/ URL in your browser.

You can scale up the containers

# Scale up the users service to 2 instances
docker-compose up -d --scale users=2

You can scale up the WWW service as well. Traefik is load balancing the requests to instances.

# Scale up the WWW service to 2 instances
docker-compose up -d --scale www=2

🏨 Running as mixed

Coherent services are running in the same container and communicate via NATS.

cd docker/mixed
docker-compose up -d --build
# or
# ./start.sh

Open the http://docker-machine:3000/ URL in your browser.

You can scale up the containers

# Scale up the group1 container to 2 instances
docker-compose up -d --scale group1=2

🔧 Development locally

Running MongoDB is required on localhost!

npm run dev

☁️ Development in Docker (without dependencies)

In this case you don't need MongoDB, what is more, you don't need NodeJS environment. Everything is in Docker.

cd docker/dev
docker-compose up -d --build

If you change source files, the app will be restarted automatically.

License

This repo is available under the MIT license.

Contact

Copyright (c) 2016-2020 MoleculerJS

@moleculerjs @MoleculerJS