Last active
January 31, 2020 04:44
-
-
Save athlona64/b3f401f73123becb0a0a4d61ff16c397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //index.js | |
| //importing node framework | |
| var express = require(‘express’); | |
| var app = express(); | |
| //Respond with "hello world" for requests that hit our root "/" | |
| app.get(‘/’, function (req, res) { | |
| res.send(‘hello world’); | |
| }); | |
| //listen to port 3000 by default | |
| app.listen(process.env.PORT || 3000); | |
| module.exports = app; | |
| ///test/test.js file | |
| var request = require(‘supertest’); | |
| var app = require(‘../index.js’); | |
| describe(‘GET /’, function() { | |
| it(‘respond with hello world’, function(done) { | |
| //navigate to root and check the the response is "hello world" | |
| request(app).get(‘/’).expect(‘hello world’, done); | |
| }); | |
| }); | |
| //install jenkins | |
| sudo add-apt-repository ppa:webupd8team/java | |
| sudo apt install oracle-java8-installer | |
| wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - | |
| sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/" | |
| sudo apt-get update | |
| sudo apt install jenkins | |
| sudo ufw allow 8080 | |
| http://JENKINS.SERVER.IP:8080 | |
| //script/deploy | |
| #!/bin/sh | |
| ssh [email protected] <<EOF | |
| cd ~/node-app | |
| git pull | |
| npm install — production | |
| pm2 restart all | |
| exit | |
| EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment