jenkins部署后端node项目(docker)

 JenkinsFile:

pipeline {
    agent {
        docker {
            image 'node:12'
            args '-p 81:81'
        }
    }
    environment { 
        CI = 'true'
    }
    stages {
        stage('install') {
            steps {
                sh 'yarn'
            }
        }
        stage('server') {
            steps {
                sh 'yarn dockerStart'
            }
        }
    }
}

package.json:

{
  "name": "m-node",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js",
    "build": "node app",
    "server": "set PORT=81 && nodemon --inspect app",
    "dockerStart": "PORT=81 node app"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "compression": "^1.7.4",
    "connect-history-api-fallback": "^1.6.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "html-to-md": "^0.5.0",
    "http-proxy-middleware": "^2.0.0",
    "mockjs": "^1.1.0",
    "moment": "^2.29.1",
    "multer": "^1.4.2",
    "node-html-markdown": "^1.1.1",
    "nodemailer": "^6.6.3",
    "sqlite3": "^5.0.2",
    "uuid": "^8.3.2"
  }
}

 

 

posted @ 2021-09-26 15:13  徐同保  阅读(2)  评论(0编辑  收藏  举报  来源