Giter Site home page Giter Site logo

kangsheng89 / nodejs-mysql-crud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chapagain/nodejs-mysql-crud

0.0 0.0 0.0 1.57 MB

Node.js, Express & MySQL: Simple Add, Edit, Delete, View (CRUD)

License: MIT License

JavaScript 60.16% EJS 19.91% Dockerfile 1.93% Python 14.38% Shell 3.62%

nodejs-mysql-crud's Introduction

Node.js, Express & MySQL: Simple Add, Edit, Delete, View (CRUD)

A simple and basic CRUD application (Create, Read, Update, Delete) using Node.js, Express, MySQL & EJS Templating Engine.

Blog: Node.js, Express & MySQL: Simple Add, Edit, Delete, View (CRUD)

Creating database and table

create database test;

use test;

CREATE TABLE users (
id int(11) NOT NULL auto_increment,
name varchar(100) NOT NULL,
age int(3) NOT NULL,
email varchar(100) NOT NULL,
PRIMARY KEY (id)
);

Create Image

To Create the Image for the apps

docker build . -t webapp

Testing

For testing in local, use the command below

docker run -p 80:4000 --env-file ./.env-sample -d webapp
curl localhost

CI/CD Pipeline

The Pipeline is organize into the section as below

Build the docker

docker build . -t webapp${GIT_COMMIT:0:6}

Tag and Storing the Docker image to ECR

it will triggered the Jenkins to build, push docker image,

docker tag webapp:${GIT_COMMIT:0:6} public.ecr.aws/e8j9l0l6/webapp:${GIT_COMMIT:0:6}
docker push public.ecr.aws/e8j9l0l6/webapp:${GIT_COMMIT:0:6} 

Deployment

The deployement is using Jenkinsfile throught the branch strategy

When the changes push to release branch, update the launch Template userdata and trigger the ASG to refresh instance

python3 deploy.py ${GIT_COMMIT:0:6}

Explaination for Deploy

This is the exampe of deployment through Python Boto3 API

Logic Flow

  1. call get_launch_template() to get the current version of launch template
  2. call describe_launch_tmp(version) to get the details of the launch template
  3. use get_data() to get the userdata from launch template
  4. use gen_code_from_template(commit) to generate new base64 encoded userdata from template file (user_data.tpl)
  5. override the data from get_data function
  6. Create new launch template from current version using create_launch_tmp(version, data)
  7. update launch template and update AutoScallingGroup
  8. Lastly refresh the ASG instances via refresh_asg_instance()

Reference

https://boto3.amazonaws.com/v1/documentation/api/latest/index.html https://docs.docker.com/engine/reference/commandline/docker/ https://www.jenkins.io/doc/book/pipeline/syntax/

nodejs-mysql-crud's People

Contributors

kangsheng89 avatar chapagain avatar bunglegrind 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.