ko build

ko build

Build and publish container images from the given importpaths.

Synopsis

This sub-command builds the provided import paths into Go binaries, containerizes them, and publishes them.

  1. ko build IMPORTPATH... [flags]

Examples

  1. # Build and publish import path references to a Docker Registry as:
  2. # ${KO_DOCKER_REPO}/<package name>-<hash of import path>
  3. # When KO_DOCKER_REPO is ko.local, it is the same as if --local and
  4. # --preserve-import-paths were passed.
  5. # If the import path is not provided, the current working directory is the
  6. # default.
  7. ko build github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
  8. # Build and publish a relative import path as:
  9. # ${KO_DOCKER_REPO}/<package name>-<hash of import path>
  10. # When KO_DOCKER_REPO is ko.local, it is the same as if --local and
  11. # --preserve-import-paths were passed.
  12. ko build ./cmd/blah
  13. # Build and publish a relative import path as:
  14. # ${KO_DOCKER_REPO}/<import path>
  15. # When KO_DOCKER_REPO is ko.local, it is the same as if --local was passed.
  16. ko build --preserve-import-paths ./cmd/blah
  17. # Build and publish import path references to a Docker daemon as:
  18. # ko.local/<import path>
  19. # This always preserves import paths.
  20. ko build --local github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah

Options

  1. --bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags).
  2. -B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags).
  3. --disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container.
  4. -h, --help help for build
  5. --image-label strings Which labels (key=value) to add to the image.
  6. --image-refs string Path to file where a list of the published image references will be written.
  7. --insecure-registry Whether to skip TLS verification on the registry
  8. -j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS)
  9. -L, --local Load into images to local docker daemon.
  10. --oci-layout-path string Path to save the OCI image layout of the built images
  11. --platform strings Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
  12. -P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
  13. --push Push images to KO_DOCKER_REPO (default true)
  14. --sbom string The SBOM media type to use (none will disable SBOM synthesis and upload, also supports: spdx, cyclonedx, go.version-m). (default "spdx")
  15. --sbom-dir string Path to file where the SBOM will be written.
  16. --tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated.
  17. -t, --tags strings Which tags to use for the produced image instead of the default 'latest' tag (may not work properly with --base-import-paths or --bare). (default [latest])
  18. --tarball string File to save images tarballs

Options inherited from parent commands

  1. -v, --verbose Enable debug logs

SEE ALSO

  • ko - Rapidly iterate with Go, Containers, and Kubernetes.