/microservices-docker-go-mongodb

Example of Microservices in Go with Docker and MongoDB

Primary LanguageGo

Cinema - Example of Microservices in Go with Docker and MongoDB

Overview

Cinema is an example project which demonstrates the use of microservices for a fictional movie theater. The Cinema backend is powered by 4 microservices, all of witch happen to be written in Go, using MongoDB for manage the database and Docker to isolate and deploy the ecosystem.

  • Movie Service: Provides information like movie ratings, title, etc.
  • Show Times Service: Provides show times information.
  • Booking Service: Provides booking information.
  • Users Service: Provides movie suggestions for users by communicating with other services.

The Cinema use case is based on the project written in Python by Umer Mansoor.

The proyect structure is based in the knowledge learned in the book: Web Development with Go by Shiju Varghese, ISBN 978-1-4842-1053-6

Full multilanguage documentation with screenshots here.

Requirements

  • Docker 1.12
  • Docker Compose 1.8

We must add virtual domains in order to use each api entry point. By default we are using: movies.local, bookings.local, users.local and showtimes.local

Virtual domains has been defined in docker-compose.yml file and configured in /etc/hosts file. Add the following line in your /etc/hosts file:

127.0.0.1   movies.local bookings.local users.local showtimes.local

Starting services

docker-compose up -d

Stoping services

docker-compose stop

Including new changes

If you need change some source code you can deploy it typing:

docker-compose build

Restore database information

You can start using an empty database for all microservices, but if you want you can restore a preconfigured data following this steps:

Access to mongodb container typing:

docker exec -it cinema-db /bin/bash

Restore data typing:

/backup/restore.sh

Leave the container:

exit

Documentation

User Service

This service returns information about the users of Cinema.

Routes:

Movie Service

This service is used to get information about a movie. It provides the movie title, rating on a 1-10 scale, director and other information.

Routes:

Showtimes Service

This service is used get a list of movies playing on a certain date.

Routes:

Booking Service

Used to lookup booking information for users.

Routes:

Significant Revisions