Skip to content
Branch: master
Find file History
Latest commit c677df5 Jul 8, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
docker blog: migrate to 0.13 Jun 19, 2018
mixins blog: add cache cleaner mixin Feb 28, 2018
models add like service & model Jul 22, 2017
public add favicon Jul 6, 2017
services blog: migrate to 0.13 Jun 19, 2018
views rename org Feb 28, 2018
.dockerignore update deps Mar 4, 2018
.editorconfig update deps Mar 4, 2018
Dockerfile update deps Mar 4, 2018
README.md update scale command Jul 8, 2018
moleculer.config.js blog: add cache cleaner mixin Feb 28, 2018
package-lock.json update blog deps Jul 8, 2018
package.json update blog deps Jul 8, 2018

README.md

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-2018 MoleculerJS

@moleculerjs @MoleculerJS

You can’t perform that action at this time.