Skip to content

Commit

Permalink
Merge pull request #819 from BenTheElder/smaller-images
Browse files Browse the repository at this point in the history
add environment defaulting with GOFLAGS=-tags=providerless to docker …
  • Loading branch information
k8s-ci-robot authored Aug 27, 2019
2 parents b901e47 + 1d2ad02 commit d09eb6e
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions pkg/internal/build/kube/dockerbuildbits.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (b *DockerBuildBits) Build() error {
// TODO(bentheelder): drop support for building without this once we've
// dropped older releases or gotten support for `make quick-release-images`
// back ported to them ...
// https://github.com/kubernetes/kubernetes/commit/037fabd842df48d0b45904b219643ca46a4ae607
releaseImagesSH := filepath.Join(
b.kubeRoot, "build", "release-images.sh",
)
Expand All @@ -93,6 +94,23 @@ func dockerBuildOsAndArch() string {

// binary and image build when we have `make quick-release-images` support
func (b *DockerBuildBits) build() error {
// we will pass through the environment variables, prepending defaults
// NOTE: if env are specified multiple times the last one wins
env := append(
[]string{
// ensure the build isn't especially noisy..
"KUBE_VERBOSE=0",
// we don't want to build these images as we don't use them ...
"KUBE_BUILD_HYPERKUBE=n",
"KUBE_BUILD_CONFORMANCE=n",
// build for the host platform
"KUBE_BUILD_PLATFORMS=" + dockerBuildOsAndArch(),
// leverage in-tree-cloud-provider-free builds by default
// https://github.com/kubernetes/kubernetes/pull/80353
"GOFLAGS=-tags=providerless",
},
os.Environ()...,
)
// build binaries
what := []string{
// binaries we use directly
Expand All @@ -102,27 +120,15 @@ func (b *DockerBuildBits) build() error {
}
cmd := exec.Command(
"build/run.sh",
"make", "all",
"WHAT="+strings.Join(what, " "),
"KUBE_BUILD_PLATFORMS="+dockerBuildOsAndArch(),
// ensure the build isn't especially noisy..
"KUBE_VERBOSE=0",
)
cmd.SetEnv(os.Environ()...)
"make", "all", "WHAT="+strings.Join(what, " "),
).SetEnv(env...)
exec.InheritOutput(cmd)
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "failed to build binaries")
}

// build images
cmd = exec.Command(
"make", "quick-release-images",
// we don't want to build these images as we don't use them...
"KUBE_BUILD_HYPERKUBE=n",
"KUBE_BUILD_CONFORMANCE=n",
"KUBE_BUILD_PLATFORMS="+dockerBuildOsAndArch(),
)
cmd.SetEnv(os.Environ()...)
cmd = exec.Command("make", "quick-release-images").SetEnv(env...)
exec.InheritOutput(cmd)
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "failed to build images")
Expand Down Expand Up @@ -190,6 +196,7 @@ func (b *DockerBuildBits) buildBash() error {
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "failed to build images")
}

return nil
}

Expand Down

0 comments on commit d09eb6e

Please sign in to comment.