Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch1 from master #14

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
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
29 changes: 29 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pipeline {
agent {
docker {
image 'node:8-alpine'
args '-p 3001:3001
-p 3020:27017
'
}

}
stages {
stage('BUILD') {
steps {
sh 'npm install'
}
}

stage('Test') {
steps {
sh 'node --version
./jenkins/scripts/test.sh'
}
}

}
environment {
HOME = '.'
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# docker-demo
46 changes: 28 additions & 18 deletions misc/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
node {
def commit_id
stage('Preparation') {
checkout scm
sh "git rev-parse --short HEAD > .git/commit-id"
commit_id = readFile('.git/commit-id').trim()
}
stage('test') {
nodejs(nodeJSInstallationName: 'nodejs') {
sh 'npm install --only=dev'
sh 'npm test'
}
}
stage('docker build/push') {
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') {
def app = docker.build("wardviaene/docker-nodejs-demo:${commit_id}", '.').push()
}
}
pipeline {
agent {
docker {
image 'node:8-alpine'
args '-p 3001:3001
-p 3020:27017
'
}

}
stages {
stage('BUILD') {
steps {
sh 'npm install'
}
}

stage('Test') {
steps {
sh 'node --version
./jenkins/scripts/test.sh'
}
}

}
environment {
HOME = '.'
}
}
19 changes: 19 additions & 0 deletions misc/Jenkinsfile copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
node {
def commit_id
stage('Preparation') {
checkout scm
sh "git rev-parse --short HEAD > .git/commit-id"
commit_id = readFile('.git/commit-id').trim()
}
stage('test') {
nodejs(nodeJSInstallationName: 'nodejs') {
sh 'npm install --only=dev'
sh 'npm test'
}
}
stage('docker build/push') {
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') {
def app = docker.build("iwaydocker/summitt:${commit_id}", '.').push()
}
}
}
34 changes: 16 additions & 18 deletions misc/Jenkinsfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@ node {
sh "git rev-parse --short HEAD > .git/commit-id"
commit_id = readFile('.git/commit-id').trim()
}
stage('test') {
def myTestContainer = docker.image('node:4.6')
myTestContainer.pull()
myTestContainer.inside {
sh 'npm install --only=dev'
sh 'npm test'
}
}
stage('test with a DB') {
def mysql = docker.image('mysql').run("-e MYSQL_ALLOW_EMPTY_PASSWORD=yes")
def myTestContainer = docker.image('node:4.6')
myTestContainer.pull()
myTestContainer.inside("--link ${mysql.id}:mysql") { // using linking, mysql will be available at host: mysql, port: 3306

stage('Run tests with a Mongo DB') {
def dockerMongoImage = docker.image("mongo")
def myTestContainer = docker.image('node:4.6')
myTestContainer.pull()
dockerMongoImage.pull()

dockerMongoImage.withRun{mongo ->
myTestContainer.inside("--link=${mongo.id}:mongo") {

sh 'npm install --only=dev'
sh 'npm test'
}
mysql.stop()
sh 'npm test'
}

}
}
stage('docker build/push') {
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') {
def app = docker.build("wardviaene/docker-nodejs-demo:${commit_id}", '.').push()
def app = docker.build("iwaydocker/summitt:${commit_id}", '.').push()
}
}
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"dependencies": {
"express": "^4.14.0",
"http-errors": "^1.7.0",
"mysql": "^2.10.2"
"mysql": "^2.10.2",
"mongoose": "^5.6.8",
"mongoose-mpath": "^2.0.19",
"mongoose-seed": "^0.6.0"
},
"devDependencies": {
"inherits": "^2.0.3",
Expand Down