load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
load("@io_bazel_rules_docker//container:bundle.bzl", "container_bundle")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

# gazelle:ignore

container_bundle(
    name = "bundle",
    images = {
        "pebble:bazel": ":image",
    },
    tags = ["manual"],
)

container_image(
    name = "nonroot_go_image_static",
    base = "@go_image_static//image",
    # See https://github.com/GoogleContainerTools/distroless/blob/2cac07c7c62b2dc52c4274a1810939fb06039ab9/base/base.bzl#L9
    user = "65532",
)

go_image(
    name = "image",
    base = ":nonroot_go_image_static",
    binary = ":app",
    tags = ["manual"],
    visibility = ["//visibility:public"],
)

go_binary(
    name = "app",
    embed = ["@org_letsencrypt_pebble//cmd/pebble:go_default_library"],
    pure = "on",
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [":package-srcs"],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
