Skip to content

Commit

Permalink
Changing kansiter Travis to use build image (#6180)
Browse files Browse the repository at this point in the history
* Changing kansiter Travis to use build image

adding --net host so we can access kind cluster
switching from bash execution to docker one
executing make as sudo

* copypaste issue
  • Loading branch information
Ilya Kislenko committed Jul 30, 2019
1 parent a7c7e1b commit 6888049
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ env:
- CHANGE_MINIKUBE_NONE_USER=true GO111MODULE=on

before_install:
- sudo bash build/local_kubernetes.sh get_localkube
- wget --progress=dot:mega https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
- sudo chmod +x kubectl
- sudo mv kubectl /usr/local/bin/kubectl

script:
- go mod download
- make build DOCKER_BUILD=false
- sudo make build
- make docs
- sudo bash build/local_kubernetes.sh start_localkube
- make test DOCKER_BUILD=false
- docker run -ti --rm --net host -e GOPATH=/go -v ${GOPATH}:/go -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/.kube:/root/.kube -v $(pwd):/data -w /data --entrypoint="bash" kanisterio/build:v0.0.1 -c "bash build/local_kubernetes.sh start_localkube"
- sudo make test

after_script:
- sudo bash build/local_kubernetes.sh stop_localkube
- docker run -ti --rm --net host -e GOPATH=/go -v ${GOPATH}:/go -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/.kube:/root/.kube -v $(pwd):/data -w /data --entrypoint="bash" kanisterio/build:v0.0.1 -c "bash build/local_kubernetes.sh stop_localkube"

10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ all-push: $(addprefix push-, $(ALL_ARCH))

build: bin/$(ARCH)/$(BIN)

bin/$(ARCH)/$(BIN):
bin/$(ARCH)/$(BIN):
@echo "building: $@"
@$(MAKE) run CMD='-c " \
GOARCH=$(ARCH) \
Expand All @@ -105,14 +105,15 @@ shell: build-dirs
-ti \
--rm \
--privileged \
-v "$(PWD)/.go/pkg:/go/pkg" \
--net host \
-v "$(PWD)/.go/pkg:/go/pkg" \
-v "$(PWD):/go/src/$(PKG)" \
-v "$(PWD)/bin/$(ARCH):/go/bin" \
-v "$(PWD)/bin/$(ARCH):/go/bin/$$(go env GOOS)_$(ARCH)" \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
/bin/sh
/bin/sh

DOTFILE_IMAGE = $(subst :,_,$(subst /,_,$(IMAGE))-$(VERSION))

Expand Down Expand Up @@ -193,6 +194,7 @@ ifeq ($(DOCKER_BUILD),"true")
@echo "running CMD in the containerized build environment"
@docker run \
--rm \
--net host \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v "${HOME}/.kube:/root/.kube" \
-v "$(PWD)/.go/pkg:/go/pkg" \
Expand All @@ -206,7 +208,7 @@ else
@/bin/bash $(CMD)
endif

clean: dotfile-clean bin-clean
clean: dotfile-clean bin-clean

dotfile-clean:
rm -rf .container-* .dockerfile-* .push-* .vendor .deploy-*
Expand Down
4 changes: 4 additions & 0 deletions build/local_kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ start_localkube() {
}

stop_localkube() {
if ! command -v kind
then
get_localkube
fi
kind delete cluster --name ${LOCAL_CLUSTER_NAME}
}

Expand Down

0 comments on commit 6888049

Please sign in to comment.