Code Monkey home page Code Monkey logo

simple-microservice-nodejs's Introduction

simple-microservice-nodejs

Simple Micro-service with NodeJS

License: MIT

Introduction

Step by step to create environment for application execution. The instructions below are for Linux OS.

Getting Started

  1. Install Docker
  2. Prepare Containers
  3. Execute Application

Contribute

  • Helio Nogueira

1. Install Docker

For install Docker, follow the instructions in Docker.


2. Prepare Containers

Instructions for preparing application containers.

2.1. Packages

$ mkdir -p "${HOME}/workspace"
$ cd "${HOME}/workspace"
$ git clone "https://github.com/helionogueir/simple-microservice-nodejs.git"
$ cd "${HOME}/workspace/simple-microservice-nodejs"
$ cp "config.example.json" "config.json" 

2.2. Database Container

Follow the instructions below.

$ docker run \
    --name "simple-microservice-nodejs-database" \
    --env "MYSQL_ROOT_PASSWORD=root" \
    --detach "mysql:5.7"

2.3. Populate Datase

Follow the instructions below.

$ docker exec -it "simple-microservice-nodejs-database" /bin/bash
$ mysql -uroot -proot

If you're seeing "mysql>" in your display, means you're connected. Now follow the instructions below.

mysql> CREATE SCHEMA `simple-microservice-nodejs` DEFAULT CHARACTER SET utf8;
mysql> USE `simple-microservice-nodejs`;
mysql> CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(18) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `age` int(3) NOT NULL,
  `created` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
mysql> INSERT INTO `users` (`name`, `age`) VALUES ('August Maynard', '18');
INSERT INTO `users` (`name`, `age`) VALUES ('Owais Gibson', '57');
INSERT INTO `users` (`name`, `age`) VALUES ('Shay Tillman', '38');
INSERT INTO `users` (`name`, `age`) VALUES ('Ryley Klein', '11');
INSERT INTO `users` (`name`, `age`) VALUES ('Vinay Dunne', '12');
INSERT INTO `users` (`name`, `age`) VALUES ('Esme Wagstaff', '15');
INSERT INTO `users` (`name`, `age`) VALUES ('Skylar Olsen', '98');
INSERT INTO `users` (`name`, `age`) VALUES ('Manuel Butler', '112');
INSERT INTO `users` (`name`, `age`) VALUES ('Kamron Lam', '1');
INSERT INTO `users` (`name`, `age`) VALUES ('Buddy Gilmore', '33');
mysql> SELECT * FROM `users`;

2.4. Application Container

Follow the instructions below.

$ docker run \
    --name "simple-microservice-nodejs-application" \
    --volume "${HOME}/workspace/simple-microservice-nodejs":/var/www/application \
    --link "simple-microservice-nodejs-database" \
    --tty --interactive node:8.10 /bin/bash

3. Execute Application

Here you will prepare and execute the application. Follow the instructions below. You need connected on container "simple-microservice-nodejs-application".

$ cd "/var/www/application"
$ npm install
$ npm start

simple-microservice-nodejs's People

Contributors

helionogueir avatar

Watchers

 avatar James Cloos 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.