diff --git a/Dockerfile b/Dockerfile index 0c38154a..27a104d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,18 @@ -FROM registry.opensource.zalan.do/stups/alpine:UPSTREAM -MAINTAINER Team Teapot @ Zalando SE +# builder image +FROM golang:1.8 as builder + +RUN go get github.com/Masterminds/glide +WORKDIR /go/src/github.com/zalando-incubator/kube-ingress-aws-controller +COPY . . +RUN glide install --strip-vendor +RUN make test +RUN make build.linux -# add scm-source -ADD scm-source.json / +# final image +FROM registry.opensource.zalan.do/stups/alpine:latest +MAINTAINER Team Teapot @ Zalando SE -# add binary -ADD build/linux/kube-aws-ingress-controller / +COPY --from=builder /go/src/github.com/zalando-incubator/kube-ingress-aws-controller/build/linux/kube-ingress-aws-controller \ + /bin/kube-ingress-aws-controller -ENTRYPOINT ["/kube-aws-ingress-controller"] +ENTRYPOINT ["/bin/kube-ingress-aws-controller"] diff --git a/Makefile b/Makefile index 11ef13ef..b15f61e0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: clean check build.local build.linux build.osx build.docker build.push -BINARY ?= kube-aws-ingress-controller +BINARY ?= kube-ingress-aws-controller VERSION ?= $(shell git describe --tags --always --dirty) IMAGE ?= registry-write.opensource.zalan.do/teapot/$(BINARY) TAG ?= $(VERSION) @@ -46,14 +46,8 @@ build/linux/$(BINARY): $(SOURCES) build/osx/$(BINARY): $(SOURCES) GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" . -$(DOCKERFILE).upstream: $(DOCKERFILE) - sed "s@UPSTREAM@$(shell $(shell head -1 $(DOCKERFILE) | sed -E 's@FROM (.*)/(.*)/(.*):.*@pierone latest \2 \3 --url \1@'))@" $(DOCKERFILE) > $(DOCKERFILE).upstream - -build.docker: $(DOCKERFILE).upstream scm-source.json build.linux - docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE).upstream . +build.docker: build.linux + docker build -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) . build.push: build.docker docker push "$(IMAGE):$(TAG)" - -scm-source.json: .git - @echo '{"url": "$(GITURL)", "revision": "$(GITHEAD)", "author": "$(USER)", "status": "$(GITSTATUS)"}' > scm-source.json diff --git a/README.md b/README.md index 4b181d12..13260ca8 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ registry of your choice. To deploy the ingress controller, use the [example YAML](deploy/ingress-controller.yaml) as the descriptor. You can customize the image used in the example YAML file. -We provide `registry.opensource.zalan.do/teapot/kube-aws-ingress-controller:latest` as a publicly usable Docker image +We provide `registry.opensource.zalan.do/teapot/kube-ingress-aws-controller:latest` as a publicly usable Docker image built from this codebase. You can deploy it with 2 easy steps: - Replace the placeholder for your region inside the example YAML, for ex., `eu-west-1` - Use kubectl to execute the command `kubectl apply -f deploy/ingress-controller.yaml` diff --git a/delivery.yaml b/delivery.yaml index 7382117f..a186fe0f 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -1,28 +1,18 @@ build_steps: - - desc: 'Install required build software' - cmd: | - apt-get update - apt-get install -y make git apt-transport-https ca-certificates \ - curl software-properties-common python-software-properties - - desc: 'Install go' - cmd: | - add-apt-repository -y ppa:longsleep/golang-backports - apt-get update - apt-get install -y golang-go - - desc: 'Install Docker' - cmd: | - curl -sSL https://get.docker.com/ | sh - - desc: 'Symlink sources into the GOPATH' - cmd: | - export GOPATH=$HOME/go - export PKG_BASE_PATH=$GOPATH/src/github.com/zalando-incubator - mkdir -p $PKG_BASE_PATH - ln -s $(pwd) $PKG_BASE_PATH/kube-ingress-aws-controller - - desc: 'Build & push docker image' - cmd: | - export PATH=$PATH:$HOME/go/bin - IS_PR_BUILD=${CDP_PULL_REQUEST_NUMBER+"true"} - if [[ ${CDP_TARGET_BRANCH} == "master" && ${IS_PR_BUILD} != "true" ]] - then - make build.push - fi \ No newline at end of file +- desc: Install docker + cmd: | + apt-get update + apt-get install -y apt-transport-https ca-certificates curl software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge" + apt-get update + apt-get install -y docker-ce +- desc: Build and push docker image + cmd: | + image=registry-write.opensource.zalan.do/teapot/kube-ingress-aws-controller:${CDP_BUILD_VERSION} + docker build --tag $image . + IS_PR_BUILD=${CDP_PULL_REQUEST_NUMBER+"true"} + if [[ ${CDP_TARGET_BRANCH} == "master" && ${IS_PR_BUILD} != "true" ]] + then + docker push $image + fi diff --git a/deploy/ingress-controller.yaml b/deploy/ingress-controller.yaml index 5b25a524..e48b72ca 100644 --- a/deploy/ingress-controller.yaml +++ b/deploy/ingress-controller.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: controller - image: registry.opensource.zalan.do/teapot/kube-aws-ingress-controller:latest + image: registry.opensource.zalan.do/teapot/kube-ingress-aws-controller:latest env: - name: AWS_REGION value: $YOUR_REGION