Code Monkey home page Code Monkey logo

ci-cd's Introduction

CI/CD for simple NodeJs APP with unit tests

Technology

  • NodeJS with restify framework

  • Docker

  • Ansible

  • Jenkins

Development Setup:

  • run "sudo .prepare-dev.sh" bash script to prepare the environment for node.js development

Jenkins Setup:

  • under setup directory, add your own public key"use ssh-keygen" to "pre.sh" and run it

  • run ansible-playbook prepare-env.yml to install java and Jenkins

  • under CI-CD directory,

    on your server add jenkins user to docker group

    usermod -aG docker jenkins

navigate http://your-ip:8080/pluginManager/available

search for this plugin "CloudBees Docker Build and Publish"

click Download Now and check the box to restart

  • get the latest version of the source code, to build docker image, to upload docker image to hub.docker.com

How create a pipeline?

1- select New Item from left side

2- enter the name and select the pipelin type

3- copy the content of Jenkinsfile to the pipeline

How to use pipeline syntax?

Navugate http://your-ip:8080/job/job-name/pipeline-syntax/

-> select git and prvoide the repo url and username/password"if it is a private", it will generate the syntax for you

-> select the withdocker-registry which installed before and provide it with credtanials

  • run following script to install and configure Jenkins

  • Document steps to setup Jenkins job to get the latest version of the source code, to build docker image, to upload docker image to hub.docker.com

How to run container:

  • install Docker

    curl -fsSL get.docker.com -o get-docker.sh

    sh get-docker.sh

  • Build the image

    docker build -t docker-demo:1 .

  • Run a Container

    docker run -d -p 80:3000 docker-demo:1

Testing:

cd nodejs-endpoint-container

npm install

npm test

Results:

Root Directory Test

Should Behave properly on GETing /

✓ should call next

✓ should call send on resp

✓ should call send on resp with Hello World as a message

✓ should have json as the content type of the respones

ci-cd's People

Contributors

m-ayman avatar malathic7 avatar

Watchers

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