Merge pull request #155 from priyawadhwa/certs-bug

Switch to multi-stage dockerfile for building kaniko
This commit is contained in:
priyawadhwa 2018-04-27 15:26:05 -07:00 committed by GitHub
commit 3575e0df6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 32 deletions

View File

@ -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 .

View File

@ -14,8 +14,13 @@
# Builds the static Go image to execute in a Kubernetes job
FROM golang:1.10
WORKDIR /go/src/github.com/GoogleContainerTools/kaniko
COPY . .
RUN make
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/

View File

@ -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}"]

View File

@ -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