From 436db3e1ebea842cd65e9e88cc617ca7cc79f796 Mon Sep 17 00:00:00 2001 From: Jakub Gumowski Date: Tue, 28 Dec 2021 21:42:46 +0100 Subject: [PATCH] Jenkins + pm2 with nuxt conf --- Jenkinsfile | 28 +++++++++++++++++++++++++--- ecosystem.config.js | 11 +++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 ecosystem.config.js diff --git a/Jenkinsfile b/Jenkinsfile index 476efa7..33f4cb7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,11 +10,33 @@ pipeline { stages { stage('Build') { steps { - sh 'npm install --production' - sh 'npm run build' - sh 'npm run start' + sh 'npm install --production' + sh 'npm run build' } } + + stage('Deploy') { + steps { + sshPublisher( + continueOnError: false, + failOnError: true, + publishers: [ + sshPublisherDesc( + configName: "frontent-deploy", + transfers: [ + sshTransfer(sourceFiles: '**/*', excludes:'**/npm_modules/**'), + sshTransfer(execCommand: """cd /var/www/html \ + && npm install --production \ + && npm run build""") + ], + verbose: true + ) + ] + ) + + // discordSend description: "Jenkins Pipeline Build", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: "https://discord.com/api/webhooks/921884411178418187/3st2Z5P9mxJnI2haY7eB9Pipwt8jn5noi8jm5AOt53B2DoxoxWaKVXXV0Dw5hmY91Da-" + } + } } } diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..6a4eb2e --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,11 @@ +module.exports = { + apps: [ + { + name: 'inzynieria_frontend', + exec_mode: 'cluster', + instances: 'max', // Or a number of instances + script: './node_modules/nuxt/bin/nuxt.js', + args: 'start' + } + ] +}