2021-10-05 11:48:57 -04:00
## ko build
2021-08-11 16:54:13 -04:00
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.
```
2021-10-05 11:48:57 -04:00
ko build IMPORTPATH... [flags]
2021-08-11 16:54:13 -04:00
```
### Examples
```
2022-06-15 23:51:40 -04:00
# Build and publish import path references to a Docker Registry as:
2021-08-11 16:54:13 -04:00
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
2022-06-15 23:51:40 -04:00
# When KO_DOCKER_REPO is ko.local, it is the same as if --local and
# --preserve-import-paths were passed.
# If the import path is not provided, the current working directory is the
# default.
2021-10-05 11:48:57 -04:00
ko build github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
2021-08-11 16:54:13 -04:00
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<package name>-<hash of import path>
2022-06-15 23:51:40 -04:00
# When KO_DOCKER_REPO is ko.local, it is the same as if --local and
# --preserve-import-paths were passed.
2021-10-05 11:48:57 -04:00
ko build ./cmd/blah
2021-08-11 16:54:13 -04:00
# Build and publish a relative import path as:
# ${KO_DOCKER_REPO}/<import path>
2022-06-15 23:51:40 -04:00
# When KO_DOCKER_REPO is ko.local, it is the same as if --local was passed.
2021-10-05 11:48:57 -04:00
ko build --preserve-import-paths ./cmd/blah
2021-08-11 16:54:13 -04:00
2022-06-15 23:51:40 -04:00
# Build and publish import path references to a Docker daemon as:
2021-08-11 16:54:13 -04:00
# ko.local/<import path>
# This always preserves import paths.
2021-10-05 11:48:57 -04:00
ko build --local github.com/foo/bar/cmd/baz github.com/foo/bar/cmd/blah
2021-08-11 16:54:13 -04:00
```
### Options
```
--bare Whether to just use KO_DOCKER_REPO without additional context (may not work properly with --tags).
-B, --base-import-paths Whether to use the base path without MD5 hash after KO_DOCKER_REPO (may not work properly with --tags).
2023-09-29 10:36:38 +02:00
--debug Include Delve debugger into image and wrap around ko-app. This debugger will listen to port 40000.
2021-08-11 16:54:13 -04:00
--disable-optimizations Disable optimizations when building Go code. Useful when you want to interactively debug the created container.
2021-10-05 11:48:57 -04:00
-h, --help help for build
2021-08-11 16:54:13 -04:00
--image-label strings Which labels (key=value) to add to the image.
2021-12-20 09:51:43 -08:00
--image-refs string Path to file where a list of the published image references will be written.
2021-08-11 16:54:13 -04:00
--insecure-registry Whether to skip TLS verification on the registry
-j, --jobs int The maximum number of concurrent builds (default GOMAXPROCS)
-L, --local Load into images to local docker daemon.
--oci-layout-path string Path to save the OCI image layout of the built images
2022-01-04 11:19:52 -08:00
--platform strings Which platform to use when pulling a multi-platform base. Format: all | <os>[/<arch>[/<variant>]][,platform]*
2021-08-11 16:54:13 -04:00
-P, --preserve-import-paths Whether to preserve the full import path after KO_DOCKER_REPO.
--push Push images to KO_DOCKER_REPO (default true)
2024-06-10 00:04:56 -04:00
--sbom string The SBOM media type to use (none will disable SBOM synthesis and upload). (default "spdx")
2022-09-20 23:44:54 +03:00
--sbom-dir string Path to file where the SBOM will be written.
2021-08-11 16:54:13 -04:00
--tag-only Include tags but not digests in resolved image references. Useful when digests are not preserved when images are repopulated.
-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])
--tarball string File to save images tarballs
```
2022-02-17 11:34:43 -05:00
### Options inherited from parent commands
```
-v, --verbose Enable debug logs
```
2021-08-11 16:54:13 -04:00
### SEE ALSO
* [ko ](ko.md ) - Rapidly iterate with Go, Containers, and Kubernetes.