GithubHelp home page GithubHelp logo

ohenning / microservice-monorepo-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 35 KB

Lightweight blueprint for managing multiple services inside a monorepo

Dockerfile 25.70% HTML 45.74% JavaScript 15.88% Python 12.68%

microservice-monorepo-boilerplate's Introduction

microservice-monorepo-boilerplate

This repo holds a simple blueprint for a starting point to a small microservice architecture application using docker and docker compose. It contains a couple example services and configurations to demonstrate the dependencies and the architecture mechanism. It does not contain any business logic or domain specific configuration and is not meant to do.

Getting started

Prerequisites

To run the application all that's needed is docker and docker-compose.

To check wether these both are already installed. Just open your terminal and run:

  • docker -v
  • docker-compose -v

Running the application

All you need to do is build the images and boot up the containers.

In your terminal navigate to the location of docker-compose.yml - it's at this projects root directory.

Run docker-compose up OR docker-compose up -d to run the containers in detach mode.

Components

The above step spins up 3 containers:

  1. website
  2. microservice-1
  3. microservice-2

website container

This container is the entry point for incoming requests. It holds a nginx server which fulfills two roles

  1. It acts as a reverse proxy to proxy-pass incoming requests on the hosts port 80 to the appropriate microservice. Therefore this container listens to incoming requests on the hosts port 80.
  2. It serves static file content such as .html files.

microservice-1 container

This container holds an example node/express apllication. This application is not exposed to a port on the host - it is only accessable inside the container network.

microservice-2 container

Same as above with the only difference that this is a python/flask application.

Deploying to a remote server

There are many different approaches for deploying this application to a server.

Here is one example using docker-hub:

In theory this works like

  1. Build the images for website, microservice-1 and microservice-2.
  2. Upload these images to your personal docker-hub.
  3. Pull these images on your remote server from docker-hub.
  4. Start the containers on your remote server.

As docker is managing all the dependencies a single container requires, the applications acts the same on a live server as on your local machine.

To actually do this:

This again is only a lightweight example with a lot of points to be improved for production use. It's for demonstrating fast results.

  1. Uncomment the image step inside docker-compose.yml and replace yourdockeruser with your docker username.
  2. Navigate to the location of docker-compose.yml
  3. Run docker-compose build. This builds the images using the Dockerfile at the location specified in the build command AND names the image with the content in the image command.
  4. Run docker-compose push. This pushes the images of the previous step to docker-hub. Make sure you are logged in to your docker-hub to be able to perform this step.
  5. Follow the instructions in docker-compose_server.yml. This file will later on be used on your remote server to pull down the images from your docker-hub.
  6. Copy docker-compose_server.yml to your remote server and rename it docker-compose.yml. Again, there are many different ways of copying this file from your local mashine to the remote server. When you got ssh access to the remote server, scp might be a handy protocol to use.
  7. On your remote server, navigate to the location of the just added docker-compose.yml file and do the exact same stuff as in the Getting started section.

microservice-monorepo-boilerplate's People

Contributors

ohenning avatar

Stargazers

Jamie Haywood avatar zeepsopje avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.