github.com/GoogleContainerTools/skaffold/v2@v2.13.2/examples/bazel/BUILD.bazel (about) 1 load("@rules_go//go:def.bzl", "go_binary", "go_library") 2 load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") 3 load("@rules_pkg//:pkg.bzl", "pkg_tar") 4 5 go_library( 6 name = "app_lib", 7 srcs = ["main.go"], 8 importpath = "example.com/custom_registry/app", 9 visibility = ["//visibility:private"], 10 ) 11 12 go_binary( 13 name = "app", 14 embed = [":app_lib"], 15 visibility = ["//visibility:public"], 16 ) 17 18 # Put app go_binary into a tar layer. 19 pkg_tar( 20 name = "app_layer", 21 srcs = [":app"], 22 # If the binary depends on RUNFILES, uncomment the attribute below. 23 # include_runfiles = True 24 ) 25 26 oci_image( 27 name = "image", 28 base = "@distroless_base", 29 entrypoint = ["/app"], 30 tars = [":app_layer"], 31 ) 32 33 # $ bazel build :skaffold-example.tar 34 # $ docker load --input $(bazel cquery --output=files :skaffold-example.tar) 35 # $ docker run --rm gcr.io/example:latest 36 37 oci_tarball( 38 name = "skaffold-example.tar", 39 # Use the image built for the exec platform rather than the target platform 40 image = ":image", 41 repo_tags = ["gcr.io/example:latest"], 42 )