Skip to content

Use multi-stage Dockerfiles for all images #3984

@joelanford

Description

@joelanford

The SDK build process currently has a pretty convoluted process for building docker images that involves several make targets and hack scripts.

I propose that we reduce this complexity by consolidating all image build steps into multi-stage Dockerfiles. With this change we will:

  1. Update Dockerfiles to perform go binary builds in a builder stage rather than copying in a pre-built binary.
  2. Update the image-build make targets to remove the make dependencies that build go binaries in the local environment
  3. Update the image-build make targets to call docker directly.
  4. Remove the hack/image-build-* scripts that are obsolete due to 3).
  5. Move all Dockerfiles into hack/image/<image-name>. They were previously split between hack/image/ and images/
  6. Move loading of images into kind from the image build step to the e2e tests where the images are actually required to be loaded into kind. Image building shouldn't be concerned with e2e setup.

This will give the project several benefits:

  1. Reproducible builds. All images will be built using identical environments, regardless if run in CI or by a developer locally.
  2. Reduce complexity. The build steps are now more self-contained in the respective Dockerfiles.
  3. Co-location in hack/image reduces the overhead of remembering where various files are for each image build.
  4. Simplified support for multiple architectures. Now that the go build happens as part of the image build, it is now much simpler to ensure the binary target architecture matches the image architecture.

There are some things I would consider out-of-scope for this:

  1. Large overhauls of the Makefile. For now, I think we can have the docker go build stage call make to build the same binaries we always have.
  2. Changes to the travis configuration and the way images are pushed and deployed.

Metadata

Metadata

Assignees

Labels

kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions