diff --git a/.goreleaser.yml b/.goreleaser.yml index becdd0eb3..5620a4ea7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -9,8 +9,6 @@ before: - go mod download # you may remove this if you don't need go generate - go generate ./... - # Pulls down the latest version of the controller's parent image - - docker pull ubuntu:18.04 builds: - id: "manager" binary: manager @@ -24,6 +22,10 @@ builds: - 386 - amd64 - arm + - arm64 + ignore: + - goos: darwin + goarch: 386 - id: "kubectl-kudo" binary: kubectl-kudo main: cmd/kubectl-kudo/main.go @@ -36,20 +38,45 @@ builds: - 386 - amd64 - arm + - arm64 + ignore: + - goos: darwin + goarch: 386 dockers: # always push a docker image on release for the .Tag version - dockerfile: Dockerfile.goreleaser binaries: - manager + goos: linux + goarch: amd64 image_templates: - "kudobuilder/controller:{{ .Tag }}" # only update the docker :latest for a full release (not RC) - dockerfile: Dockerfile.goreleaser binaries: - manager + goos: linux + goarch: amd64 image_templates: - "kudobuilder/controller:latest" skip_push: auto + # always push a docker image on release for the .Tag version + - dockerfile: Dockerfile.goreleaser + binaries: + - manager + goos: linux + goarch: arm64 + image_templates: + - "kudobuilder/controller-arm64:{{ .Tag }}" + # only update the docker :latest for a full release (not RC) + - dockerfile: Dockerfile.goreleaser + binaries: + - manager + goos: linux + goarch: arm64 + image_templates: + - "kudobuilder/controller-arm64:latest" + skip_push: auto archives: - id: kubectl-kudo-tarball builds: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39197b325..51c5df902 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,7 +59,7 @@ You can build CLI locally via `make cli`. After running that command, CLI will b #### Running new manager inside cluster For some situations, it might make sense to test your manager inside a real cluster running in a pod (not just running the binary locally). To do that you need: - build a docker image with the manager locally `DOCKER_IMG=nameofyourimage make docker-build` -- push the image to a remote repository `DOCKER_IMG=nameofyourimage make docker-push` +- push the built image to a remote repository - run `kubectl kudo init --kudo-image nameofyourimage:tag` ### Testing diff --git a/Dockerfile.amd64 b/Dockerfile similarity index 96% rename from Dockerfile.amd64 rename to Dockerfile index 32c0987ba..4d0133eba 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager \ -ldflags "${ldflags_arg}" github.com/kudobuilder/kudo/cmd/manager # Copy the controller-manager into a thin image -FROM ubuntu:18.04 +FROM scratch WORKDIR /root/ COPY --from=builder /go/src/github.com/kudobuilder/kudo/manager . ENTRYPOINT ["./manager"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index d0766aac7..000000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,23 +0,0 @@ -# Build the manager binary -FROM golang:1.14 as builder - -# Setting arguments -ARG ldflags_arg - -# Copy in the go src -WORKDIR /go/src/github.com/kudobuilder/kudo -COPY pkg/ pkg/ -COPY cmd/ cmd/ -COPY go.mod go.mod -COPY go.sum go.sum -ENV GO111MODULE on - -# Build with ldflags set -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o manager \ - -ldflags "${ldflags_arg}" github.com/kudobuilder/kudo/cmd/manager - -# Copy the controller-manager into a thin image -FROM arm64v8/ubuntu:18.04 -WORKDIR /root/ -COPY --from=builder /go/src/github.com/kudobuilder/kudo/manager . -ENTRYPOINT ["./manager"] diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 6c7e25b98..5fd1da473 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM scratch WORKDIR /root/ COPY manager /root ENTRYPOINT ["./manager"] diff --git a/Makefile b/Makefile index 658c0c7f5..90dc987c6 100644 --- a/Makefile +++ b/Makefile @@ -135,30 +135,7 @@ clean: cli-clean test-clean manager-clean deploy-clean .PHONY: docker-build # Build the docker image for each supported platform docker-build: generate lint - $(foreach arch,$(SUPPORTED_PLATFORMS),docker build --build-arg ldflags_arg="$(LDFLAGS)" -f Dockerfile.$(arch) -t $(DOCKER_IMG)-$(arch):$(DOCKER_TAG) .;) - $(foreach arch,$(SUPPORTED_PLATFORMS),docker tag $(DOCKER_IMG)-$(arch):$(DOCKER_TAG) $(DOCKER_IMG)-$(arch):v$(GIT_VERSION);) - $(foreach arch,$(SUPPORTED_PLATFORMS),docker tag $(DOCKER_IMG)-$(arch):$(DOCKER_TAG) $(DOCKER_IMG)-$(arch):latest;) - -.PHONY: docker-push-all-platforms -# Push the platform specific images for each supported arch -docker-push-platforms: - $(foreach arch,$(SUPPORTED_PLATFORMS),docker push $(DOCKER_IMG)-$(arch):$(DOCKER_TAG);) - $(foreach arch,$(SUPPORTED_PLATFORMS),docker push $(DOCKER_IMG)-$(arch):v$(GIT_VERSION);) - $(foreach arch,$(SUPPORTED_PLATFORMS),docker push $(DOCKER_IMG)-$(arch):latest;) - -.PHONY: docker-push-manifest -# Push the multi-arch image manifest -docker-push-manifests: - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend $(DOCKER_IMG):$(DOCKER_TAG) $(foreach arch,$(SUPPORTED_PLATFORMS),$(DOCKER_IMG)-$(arch):$(DOCKER_TAG)) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend $(DOCKER_IMG):v$(GIT_VERSION) $(foreach arch,$(SUPPORTED_PLATFORMS),$(DOCKER_IMG)-$(arch):v$(GIT_VERSION)) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend $(DOCKER_IMG):latest $(foreach arch,$(SUPPORTED_PLATFORMS),$(DOCKER_IMG)-$(arch):latest) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(DOCKER_IMG):$(DOCKER_TAG) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(DOCKER_IMG):v$(GIT_VERSION) - DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push --purge $(DOCKER_IMG):latest - -.PHONY: docker-push -# Push all images and manifests -docker-push: docker-push-platforms docker-push-manifests + docker build --build-arg ldflags_arg="$(LDFLAGS)" -f Dockerfile -t $(DOCKER_IMG):$(DOCKER_TAG) . .PHONY: imports # used to update imports on project. NOT a linter. diff --git a/test/Dockerfile b/test/Dockerfile index d2c5920c8..36ba40748 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -12,8 +12,7 @@ RUN apt-get update && apt-get install -y \ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \ apt-get update && apt-get install -y docker-ce-cli -COPY Dockerfile.amd64 ./Dockerfile -COPY Makefile go.mod go.sum ./ +COPY Dockerfile Makefile go.mod go.sum ./ RUN make download COPY config/ config/ COPY pkg/ pkg/