From 3705de22983692a0fa0c8b6012b219d8f52dfb1b Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 27 Apr 2018 14:34:32 -0700 Subject: [PATCH 1/2] Switch to multi-stage dockerfile for building kaniko --- deploy/Dockerfile | 8 +++++++- deploy/executor-release.yaml | 27 +-------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/deploy/Dockerfile b/deploy/Dockerfile index 0323d5d34..83c5627c4 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -14,8 +14,14 @@ # Builds the static Go image to execute in a Kubernetes job +FROM golang +WORKDIR /go/src/github.com/GoogleContainerTools/kaniko +RUN apt-get update && apt-get install -y make +COPY . . +RUN make -B + FROM scratch -COPY out/executor /kaniko/executor +COPY --from=0 /go/src/github.com/GoogleContainerTools/kaniko/out/executor /kaniko/executor COPY files/ca-certificates.crt /kaniko/ssl/certs/ COPY files/docker-credential-gcr /usr/local/bin/ COPY files/config.json /root/.docker/ diff --git a/deploy/executor-release.yaml b/deploy/executor-release.yaml index 6344ebdff..b2a2d2e69 100644 --- a/deploy/executor-release.yaml +++ b/deploy/executor-release.yaml @@ -1,31 +1,6 @@ steps: - # First, install make - - name: "gcr.io/google-appengine/debian9" - args: ["sh", "-c", "apt-get update && apt-get install -y make"] - volumes: - - name: "make" - path: "/usr/bin" - - name: "gcr.io/google-appengine/debian9" - args: ["sh", "-c", "cp -r . /kaniko/ && mkdir -p /workspace/go/src/github.com/GoogleContainerTools/ && cp -r /kaniko/ /workspace/go/src/github.com/GoogleContainerTools/"] - volumes: - - name: "make" - path: "/usr/bin" - # Then, build the binary - - name: "gcr.io/google-appengine/golang" - args: ["sh", "-c", "make"] - volumes: - - name: "make" - path: "/usr/bin" - dir: go/src/github.com/GoogleContainerTools/kaniko - env: ["GOPATH=/workspace/go/"] # First, build kaniko - name: "gcr.io/cloud-builders/docker" args: ["build", "-f", "deploy/Dockerfile", "-t", "gcr.io/kaniko-project/executor:${COMMIT_SHA}", "."] - dir: go/src/github.com/GoogleContainerTools/kaniko - # Then, build kaniko:debug - - name: "gcr.io/cloud-builders/docker" - args: ["build", "-f", "deploy/Dockerfile_debug", - "-t", "gcr.io/kaniko-project/executor:debug-${COMMIT_SHA}", "."] - dir: go/src/github.com/GoogleContainerTools/kaniko -images: ["gcr.io/kaniko-project/executor:${COMMIT_SHA}", "gcr.io/kaniko-project/executor:debug-${COMMIT_SHA}"] +images: ["gcr.io/kaniko-project/executor:${COMMIT_SHA}"] From b9435943ec689dbaf73df263698483e36e586be3 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 27 Apr 2018 14:58:25 -0700 Subject: [PATCH 2/2] clean up makefile --- Makefile | 6 ++---- deploy/Dockerfile | 5 ++--- test.sh | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index d913360ed..a00b2d386 100644 --- a/Makefile +++ b/Makefile @@ -34,13 +34,11 @@ GO_LDFLAGS += -X $(VERSION_PACKAGE).version=$(VERSION) GO_LDFLAGS += -w -s # Drop debugging symbols. GO_LDFLAGS += ' -GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs exclude_graphdriver_overlay" - EXECUTOR_PACKAGE = $(REPOPATH)/cmd/executor KANIKO_PROJECT = $(REPOPATH)/kaniko out/executor: $(GO_FILES) - GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(EXECUTOR_PACKAGE) + GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -o $@ $(EXECUTOR_PACKAGE) .PHONY: test test: out/executor @@ -51,5 +49,5 @@ integration-test: @ ./integration-test.sh .PHONY: images -images: out/executor +images: docker build -t $(REGISTRY)/executor:latest -f deploy/Dockerfile . diff --git a/deploy/Dockerfile b/deploy/Dockerfile index 83c5627c4..227a184c7 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -14,11 +14,10 @@ # Builds the static Go image to execute in a Kubernetes job -FROM golang +FROM golang:1.10 WORKDIR /go/src/github.com/GoogleContainerTools/kaniko -RUN apt-get update && apt-get install -y make COPY . . -RUN make -B +RUN make FROM scratch COPY --from=0 /go/src/github.com/GoogleContainerTools/kaniko/out/executor /kaniko/executor diff --git a/test.sh b/test.sh index 1ca29155d..d797d9f7a 100755 --- a/test.sh +++ b/test.sh @@ -21,7 +21,7 @@ GREEN='\033[0;32m' RESET='\033[0m' echo "Running go tests..." -go test -cover -v -tags "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs" -timeout 60s `go list ./... | grep -v vendor` | sed ''/PASS/s//$(printf "${GREEN}PASS${RESET}")/'' | sed ''/FAIL/s//$(printf "${RED}FAIL${RESET}")/'' +go test -cover -v -timeout 60s `go list ./... | grep -v vendor` | sed ''/PASS/s//$(printf "${GREEN}PASS${RESET}")/'' | sed ''/FAIL/s//$(printf "${RED}FAIL${RESET}")/'' GO_TEST_EXIT_CODE=${PIPESTATUS[0]} if [[ $GO_TEST_EXIT_CODE -ne 0 ]]; then exit $GO_TEST_EXIT_CODE