Skip to content

Simple web application with Node, Express and MySQL. Docker hosted (master branch)/ Vagrant+Docker hosted (vmaster branch).

License

Notifications You must be signed in to change notification settings

mjaglan/Web-Console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web console

Creating a simple web application with Node, Express and MySQL.

  • MySQL server for data
  • Node-Express Web-Server to create, update, read, and delete the data displayed on the UI as a table.

A simple usecase is to have external automation systems report new data to MySQL server. And see those data updates on the web UI. Great for those who are not required to spend much of their time building dedicated web server and ui.

How to Run

  • You need to install docker on your host. See Install-Docker-on-Ubuntu.

  • Go to your terminal.

  • Clone this repository.

  • Update MySQL password to following two files

    NOTE: Defaults are already set in the file -
    USER: root
    DB: testdb
    
  • Run following scripts to setup MySQL DB

    • Setup testbed-mysql MySQL container:

      ./ops/mysql/run-mysql-server.sh
      

      Or, if you want to remove all previous docker containers and images also, run this instead -

      ./ops/mysql/run-mysql-server.sh rmi
      
    • Setup testbed Nodejs container:

      ./ops/node-express/run-node-express-server.sh
      
  • To exit from current container without closing it press following keys 1 or 2 times

    ctrl + p + q
    

Web UI

Docker Instances

$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
baeace45220f        testbed             bridge              local
...

$ docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                     NAMES
475203aa27f7        mjaglan/expressnode   "/bin/sh -c bash"        5 minutes ago       Up 5 minutes        0.0.0.0:12000->3000/tcp   testbed
146d749c1272        mysql:5.6             "docker-entrypoint.s…"   31 minutes ago      Up 31 minutes       3306/tcp                  testbed-mysql
...

Project Structure (src/express_app)

├── .env
├── app.js
├── bin
│   └── www
├── config
│   └── log4js.json
├── package.json
├── public
│   ├── datatables (client pages)
│   ├── footable (client pages)
│   └── favicon.ico
├── routes
│   └── index.js
└── views
    ├── error.ejs
    ├── index.ejs
    └── index.html
  • .env file stores MySQL DB Credentials like this -

     DB_HOST=<mysql-host>
     DB_USER=<mysql-user>
     DB_PASS=<mysql-pwd>
    
  • app.js file is the entry-point of your application (contains the express core, such as uri parser, modules, database)

  • bin/ folder should contain the various configuration startup scripts for your application.

  • package.json file contains all of your dependencies and various details regarding your project (used by npm for dependencies and sharing).

  • public/ folder contains all of your front-end code - client static files (CSS, client JavaScript, jQuery, images, fonts, etc.)

  • routes/ folder contains all the routes that you have created for your application. Contains the main back-end code (server side), which compute data before calling a template engine (see below) or respond to the client (via json/ xml).

  • views/ folder contains all of your server-side views. Contains each page template, see jade template. These files are used by scripts in "route".

Tools

Docker version 18.03.1-ce
Ubuntu 16.04.4 LTS Host OS

References

About

Simple web application with Node, Express and MySQL. Docker hosted (master branch)/ Vagrant+Docker hosted (vmaster branch).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published