Skip to content

Commit

Permalink
Merge pull request #13 from linkernetworks/aren/VX-122-build-docker
Browse files Browse the repository at this point in the history
Aren/vx 122 build docker
  • Loading branch information
Hung-Wei Chiu authored Jun 20, 2018
2 parents 147e587 + 225343e commit f7f86e2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
19 changes: 18 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
language: go

sudo: required

services:
- mongodb
- docker

go:
- "1.10.x"
Expand All @@ -18,14 +21,28 @@ cache:
- vendor/gopkg.in
- vendor/k8s.io

install:
before_install:
- go get -u github.com/kardianos/govendor

install:
- make pre-build

script:
- make build
- make test
- make src.test-coverage
- docker build --tag sdnvortex/vortex --file ./dockerfiles/Dockerfile .

before_deploy:
- echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USER --password-stdin

deploy:
provider: script
script:
docker tag sdnvortex/vortex sdnvortex/vortex:develop
docker push sdnvortex/vortex:develop
on:
branch: develop

after_success:
- cp build/src/coverage.txt coverage.txt
Expand Down
28 changes: 28 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,33 @@ pipeline {
}
}
}
stage("Build Image"){
steps {
script {
dir ("src/github.com/linkernetworks/vortex") {
docker.build("sdnvortex/vortex" , "--file ./dockerfiles/Dockerfile .")
}
}
}
}
stage("Push Image"){
when {
branch 'develop'
}
steps {
script {
withCredentials([
usernamePassword(
credentialsId: 'eb1d8dd2-afd2-49d3-bbef-605de4f664d2',
usernameVariable: 'DOCKER_USER',
passwordVariable: 'DOCKER_PASS'
)
]) {
sh 'echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin'
}
docker.image("sdnvortex/vortex").push("develop")
}
}
}
}
}
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ GO = go
GO_VENDOR = govendor
MKDIR_P = mkdir -p

## For docker
DOCKER_REGISTRY = sdnvortex
IMAGE_TAG = latest
PROJECT = vortex
################################################

.PHONY: all
Expand Down Expand Up @@ -71,5 +67,7 @@ check-govendor:
@[ "`which $(GO_VENDOR)`" != "" ] || (echo "$(GO_VENDOR) is missing"; false)

## dockerfiles/ ########################################
docker.build:
docker build --tag $(DOCKER_REGISTRY)/$(PROJECT):$(IMAGE_TAG) -f ./dockerfiles/Dockerfile .

.PHONY: dockerfiles.build
dockerfiles.build:
docker build --tag sdnvortex/vortex:latest --file ./dockerfiles/Dockerfile .

0 comments on commit f7f86e2

Please sign in to comment.