Look here

So how do you do that? Here’s the video share link address where all the code is in the code repository, right

Use TravisCI with shipit.js for automated deployment

  • TravisCI: Testing, code coverage
  • Shipit: JS-BASED deployment engine

Some key code is posted here

Create shipitfile. Js

'use strict';

module.exports = function(shipit) {
  require('shipit-deploy')(shipit);

  shipit.initConfig({
    default: {
      workspace: '/tmp/github-monitor',
      deployTo: '/home/nono/app',
      repositoryUrl: 'https://github.com/MiYogurt/deploy-egg-sample.git',
      ignores: [ '.git'.'node_modules' ],
      rsync: [ '--del' ],
      keepReleases: 2,
      key: './scripts/source.key',
      shallowClone: true,
    },
    staging: {
      servers: '[email protected]',}}); shipit.task('docker'.function() {
    return shipit.start([ 'build'.'remove'.'create' ]);
  });

  shipit.blTask('build'.function() {
    return shipit.remote('docker build -t nodelover:v1 .', {
      cwd: '/home/nono/app/current'}); }); shipit.blTask('create'.function() {
    return shipit.remote('docker run -d --name app -p 8080:7001 nodelover:v1', {
      cwd: '/home/nono/app/current'}); }); shipit.blTask('remove'.function() {
    return shipit.remote('docker stop app', {
          cwd: '/home/nono/app/current',
        }).then(o => shipit.remote('docker rm app', {
          cwd: '/home/nono/app/current',
        })).catch(err => console.log("no need stop"))}); };Copy the code

Writing a Shell script takes less than a few lines and is much easier, but requires some Linux skills.

Dockerfile containerizes your application.

From node:9.2.0 add. /app expose 7001 workdir /app run NPM I CMD NPM run startCopy the code

.travis.yml

sudo: false
language: node_js
addons:
  ssh_known_hosts: xxx.xxx.xxx.xx
node_js:
  - '9'
before_install:
  - openssl aes-256-cbc -K $encrypted_b8bda4515144_key -iv $encrypted_b8bda4515144_iv -in scripts/source.key.enc -out scripts/source.key -d
install:
  - npm i npminstall && npminstall
# script:
# - npm run ci
after_script:
  # - npminstall codecov && codecov
  - chmod 600 scripts/source.key
  - shipit staging deploy
  - shipit staging docker
Copy the code

With these 3 core files, you can implement DOCker-based CI/CD without spending a penny, of course ordinary.

Of course, if you do not have the ability to use Docker, you can go back to the VERSION of PR.