Skip to content

Commit

Permalink
Added dockerfile and jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
James Kerr committed Aug 10, 2018
1 parent 103cc9d commit 0d7483c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:8

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "npm", "start" ]
44 changes: 44 additions & 0 deletions Jenkinsfle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
podTemplate(label: "default", cloud: "local-cluster") {
node("default") {
def buildName = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
def projectID = "quixotic-strand-159502"
def imageTag = "gcr.io/${projectID}/cluso:${env.BRANCH_NAME}.${env.BUILD_NUMBER}"
def slackBuildUrl = "<${env.BUILD_URL}|looky-desktop: ${buildName}>"

try {
stage("checkout source") {
slackSend message: "Building...\n${slackBuildUrl}"
checkout scm
}

stage("build") {
sh "docker build -t ${imageTag} ."
}

stage("unit tests") {
sh "docker run --rm -i ${imageTag} /bin/sh -c \"npm test\""
}

stage("push image") {
sh "gcloud docker -- push ${imageTag}"

if (env.BRANCH_NAME == "master") {
def latestTag = "gcr.io/${projectID}/cluso:latest"
sh("docker tag ${imageTag} ${latestTag}")
sh("gcloud docker -- push ${latestTag}")
}

}

stage("notify") {
slackSend color: "good", message: "Build Succeeded!\n${slackBuildUrl}"
}

}

catch (error) {
slackSend color: "danger", message: "Build Failed!\n${slackBuildUrl}"
throw error
}
}
}

0 comments on commit 0d7483c

Please sign in to comment.