Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,72 @@ pipeline {
archiveArtifacts artifacts: 'dist/trainSchedule.zip'
}
}
stage('Build Image') {
when {
branch 'master'
}
steps {
script {
app = docker.build("ikant3922/train-schedule")
app.inside {
sh 'echo $(curl localhost:8080)'
}
}
}
}
stage('Push Image') {
when {
branch 'master'
}
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
}
}
}
stage ('Deploy to staging') {
when {
branch 'master'
}
steps {
withCredentials ([usernamePassword(credentialsId: 'webserver_login', usernameVariable: 'USERNAME', passwordVariable: 'USERPASS')]) {
script {
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.stage_ip} \"docker pull ikant3922/train-schedule:${env.BUILD_NUMBER}\""
try {
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.stage_ip} \"docker stop train-schedule\""
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.stage_ip} \"docker rm train-schedule\""
} catch (err) {
echo: 'caught error: $err'
}
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.stage_ip} \"docker run --restart always --name train-schedule -p 80:8080 -d ikant3922/train-schedule:${env.BUILD_NUMBER}\""
}
}
}
}
stage ('Deploy to production') {
when {
branch 'master'
}
steps {
input 'Deploy to Production'
milestone(1)
withCredentials ([usernamePassword(credentialsId: 'webserver_login', usernameVariable: 'USERNAME', passwordVariable: 'USERPASS')]) {
script {
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.prod_ip} \"docker pull ikant3922/train-schedule:${env.BUILD_NUMBER}\""
try {
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.prod_ip} \"docker stop train-schedule\""
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.prod_ip} \"docker rm train-schedule\""
} catch (err) {
echo: 'caught error: $err'
}
sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@${env.prod_ip} \"docker run --restart always --name train-schedule -p 80:8080 -d ikant3922/train-schedule:${env.BUILD_NUMBER}\""
}
}
}
}
}

}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a simple train schedule app written using nodejs. It is intended to be used as a sample application for a series of hands-on learning activities.

## Running the app
## Running the app train1.1

You need a Java JDK 7 or later to run the build. You can run the build like this:

Expand All @@ -13,3 +13,5 @@ You can run the app with:
./gradlew npm_start

Once it is running, you can access it in a browser at http://localhost:8080


4 changes: 2 additions & 2 deletions public/stylesheets/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
padding: 30px;
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}

Expand Down Expand Up @@ -56,4 +56,4 @@ a {
fieldset {
border:0;
padding:0; margin:0;
}
}