diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 6aaab56..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,25 +0,0 @@ - -pipeline { - agent any - stages { - stage('Build') { - steps { - sh 'docker build -f dockerfile . -t mahmom/jenkins_node:v1.0' - } - } - stage('push') { - steps { - withCredentials([usernamePassword(credentialsId:"docker",usernameVariable:"USERNAME",passwordVariable:"PASSWORD")]){ - sh 'docker login --username $USERNAME --password $PASSWORD' - sh 'docker push mahmom/jenkins_node:v1.0' - } - - } - } - stage('Deploy') { - steps { - sh 'docker run -d -p 3000:3000 mahmom/jenkins_node:v1.0' - } - } - } -} diff --git a/nodeapp/app.js b/nodeapp/app.js index 893a8fe..f68255d 100644 --- a/nodeapp/app.js +++ b/nodeapp/app.js @@ -1,10 +1,27 @@ +const mysql = require('mysql'); const express = require('express') const app = express() const port = 3000 +const host= process.env.HOST +const user= process.env.USERNAME +const password= process.env.PASSWORD +const database= process.env.DATABASE + +const connection = mysql.createConnection({ + host: host, + user: user, + password: password, + database: database +}); +connection.connect((err) => { + if (err) throw err; + console.log('Connected!'); +}); + app.get('/', (req, res) => { res.send('Hello World!') }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) - }) \ No newline at end of file + }) diff --git a/nodeapp/package.json b/nodeapp/package.json index 85a6cee..3160557 100644 --- a/nodeapp/package.json +++ b/nodeapp/package.json @@ -10,5 +10,7 @@ "author": "", "license": "ISC", "dependencies": { - "express": "^4.17.1" } + "express": "^4.17.1", + "mysql": "^2.18.1" + } }