diff --git a/WORKSPACE b/WORKSPACE index dae3c6b073..3318dbd4ea 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -96,11 +96,22 @@ http_archive( ) http_archive( - name = "io_bazel_rules_docker", - sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf", - urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"], + name = "rules_distroless", + sha256 = "e64f06e452cd153aeab81f752ccf4642955b3af319e64f7bc7a7c9252f76b10e", + strip_prefix = "rules_distroless-f5e678217b57ce3ad2f1c0204bd4e9d416255773", + url = "https://github.com/GoogleContainerTools/rules_distroless/archive/f5e678217b57ce3ad2f1c0204bd4e9d416255773.tar.gz", ) +load("@rules_distroless//distroless:dependencies.bzl", "rules_distroless_dependencies") + +rules_distroless_dependencies() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains") + +aspect_bazel_lib_dependencies() + +aspect_bazel_lib_register_toolchains() + http_archive( name = "rules_oci", sha256 = "c71c25ed333a4909d2dd77e0b16c39e9912525a98c7fa85144282be8d04ef54c", @@ -148,67 +159,16 @@ git_repository( # gazelle args: -go_prefix github.com/gogo/protobuf -proto legacy ) -load( - "@io_bazel_rules_docker//repositories:repositories.bzl", - container_repositories = "repositories", -) - -container_repositories() - -load( - "@io_bazel_rules_docker//container:container.bzl", - "container_pull", -) - -# Pulled gcr.io/distroless/cc-debian11:latest on 2022-02-23 -container_pull( - name = "cc_image_base_amd64", - digest = "sha256:2a0daf90a7deb78465bfca3ef2eee6e91ce0a5706059f05d79d799a51d339523", - registry = "gcr.io", - repository = "distroless/cc-debian11", -) - -# Pulled gcr.io/distroless/cc-debian11:debug on 2022-02-23 -container_pull( - name = "cc_debug_image_base_amd64", - digest = "sha256:7bd596f5f200588f13a69c268eea6ce428b222b67cd7428d6a7fef95e75c052a", - registry = "gcr.io", - repository = "distroless/cc-debian11", -) - -# Pulled from gcr.io/distroless/base-debian11:latest on 2022-02-23 -container_pull( - name = "go_image_base_amd64", - digest = "sha256:34e682800774ecbd0954b1663d90238505f1ba5543692dbc75feef7dd4839e90", - registry = "gcr.io", - repository = "distroless/base-debian11", -) - -# Pulled from gcr.io/distroless/base-debian11:debug on 2022-02-23 -container_pull( - name = "go_debug_image_base_amd64", - digest = "sha256:0f503c6bfd207793bc416f20a35bf6b75d769a903c48f180ad73f60f7b60d7bd", - registry = "gcr.io", - repository = "distroless/base-debian11", -) - -container_pull( - name = "alpine_cc_linux_amd64", - digest = "sha256:752aa0c9a88461ffc50c5267bb7497ef03a303e38b2c8f7f2ded9bebe5f1f00e", - registry = "index.docker.io", - repository = "pinglamb/alpine-glibc", -) - load("@rules_oci//oci:pull.bzl", "oci_pull") # A multi-arch base image oci_pull( name = "linux_debian11_multiarch_base", # Debian bullseye - digest = "sha256:9b8e0854865dcaf49470b4ec305df45957020fbcf17b71eeb50ffd3bc5bf885d", # 2023-05-17 + digest = "sha256:b82f113425c5b5c714151aaacd8039bc141821cdcd3c65202d42bdf9c43ae60b", # 2023-12-12 image = "gcr.io/distroless/cc-debian11", platforms = [ "linux/amd64", - "linux/arm64", + "linux/arm64/v8", ], reproducible = True, ) @@ -417,24 +377,6 @@ load("@prysm//testing/endtoend:deps.bzl", "e2e_deps") e2e_deps() -load( - "@io_bazel_rules_docker//go:image.bzl", - _go_image_repos = "repositories", -) - -# Golang images -# This is using gcr.io/distroless/base -_go_image_repos() - -# CC images -# This is using gcr.io/distroless/base -load( - "@io_bazel_rules_docker//cc:image.bzl", - _cc_image_repos = "repositories", -) - -_cc_image_repos() - load("@com_github_atlassian_bazel_tools//gometalinter:deps.bzl", "gometalinter_dependencies") gometalinter_dependencies() diff --git a/cmd/beacon-chain/BUILD.bazel b/cmd/beacon-chain/BUILD.bazel index 11c01f23aa..99083b2a3f 100644 --- a/cmd/beacon-chain/BUILD.bazel +++ b/cmd/beacon-chain/BUILD.bazel @@ -1,9 +1,5 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") 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:container.bzl", "container_bundle", "container_image") -load("//tools:go_image.bzl", "go_image_debug") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( @@ -45,69 +41,6 @@ go_library( ], ) -go_image( - name = "image", - base = select({ - "//tools:base_image_cc": "//tools:cc_image", - "//conditions:default": "//tools:cc_image", - }), - binary = ":beacon-chain", - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -container_image( - name = "image_with_creation_time", - base = "image", - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/beacon-chain:latest": ":image_with_creation_time", - "gcr.io/prysmaticlabs/prysm/beacon-chain:{DOCKER_TAG}": ":image_with_creation_time", - "index.docker.io/prysmaticlabs/prysm-beacon-chain:latest": ":image_with_creation_time", - "index.docker.io/prysmaticlabs/prysm-beacon-chain:{DOCKER_TAG}": ":image_with_creation_time", - }, - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -go_image_debug( - name = "image_debug", - image = ":image", - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -container_bundle( - name = "image_bundle_debug", - images = { - "gcr.io/prysmaticlabs/prysm/beacon-chain:latest-debug": ":image_debug", - "gcr.io/prysmaticlabs/prysm/beacon-chain:{DOCKER_TAG}-debug": ":image_debug", - "index.docker.io/prysmaticlabs/prysm-beacon-chain:latest-debug": ":image_debug", - "index.docker.io/prysmaticlabs/prysm-beacon-chain:{DOCKER_TAG}-debug": ":image_debug", - }, - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - -docker_push( - name = "push_images_debug", - bundle = ":image_bundle_debug", - tags = ["manual"], - visibility = ["//beacon-chain:__pkg__"], -) - go_binary( name = "beacon-chain", embed = [":go_default_library"], @@ -134,12 +67,12 @@ go_test( ) prysm_image_upload( - name = "push_oci_image", + name = "push_images", binary = ":beacon-chain", entrypoint = ["/beacon-chain"], - repository = "gcr.io/prylabs-dev/prysm/beacon-chain", + repository = "gcr.io/prysmaticlabs/prysm/beacon-chain", symlinks = { - # Backwards compatiability for images that depended on the old filepath. + # Backwards compatibility for images that depended on the old filepath. "/app/cmd/beacon-chain/beacon-chain": "/beacon-chain", }, tags = ["manual"], diff --git a/cmd/prysmctl/BUILD.bazel b/cmd/prysmctl/BUILD.bazel index 032224910c..e1c3f62a15 100644 --- a/cmd/prysmctl/BUILD.bazel +++ b/cmd/prysmctl/BUILD.bazel @@ -1,9 +1,5 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_docker//go:image.bzl", "go_image") -load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image") -load("//tools:go_image.bzl", "go_image_debug") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( @@ -24,65 +20,6 @@ go_library( ], ) -go_image( - name = "image", - base = select({ - "//tools:base_image_cc": "//tools:cc_image", - "//conditions:default": "//tools:cc_image", - }), - binary = ":prysmctl", - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -container_image( - name = "image_with_creation_time", - base = "image", - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:latest": ":image_with_creation_time", - "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:{DOCKER_TAG}": ":image_with_creation_time", - }, - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -go_image_debug( - name = "image_debug", - image = ":image", - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -container_bundle( - name = "image_bundle_debug", - images = { - "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:latest-debug": ":image_debug", - "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:{DOCKER_TAG}-debug": ":image_debug", - }, - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - -docker_push( - name = "push_images_debug", - bundle = ":image_bundle_debug", - tags = ["manual"], - visibility = ["//cmd/prysmctl:__pkg__"], -) - go_binary( name = "prysmctl", embed = [":go_default_library"], @@ -91,10 +28,10 @@ go_binary( ) prysm_image_upload( - name = "push_oci_image", + name = "push_images", binary = ":prysmctl", entrypoint = ["/prysmctl"], - repository = "gcr.io/prylabs-dev/prysm/prysmctl", + repository = "gcr.io/prysmaticlabs/prysm/cmd/prysmctl", symlinks = { # Backwards compatiability for images that depended on the old filepath. "/app/cmd/prysmctl/prysmctl": "/prysmctl", diff --git a/cmd/validator/BUILD.bazel b/cmd/validator/BUILD.bazel index 46ca1e241e..809cc2ac86 100644 --- a/cmd/validator/BUILD.bazel +++ b/cmd/validator/BUILD.bazel @@ -1,9 +1,5 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") 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:container.bzl", "container_bundle", "container_image") -load("//tools:go_image.bzl", "go_image_debug") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( @@ -39,69 +35,6 @@ go_library( ], ) -go_image( - name = "image", - base = select({ - "//tools:base_image_cc": "//tools:cc_image", - "//conditions:default": "//tools:cc_image", - }), - binary = ":validator", - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -container_image( - name = "image_with_creation_time", - base = "image", - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/validator:latest": ":image_with_creation_time", - "gcr.io/prysmaticlabs/prysm/validator:{DOCKER_TAG}": ":image_with_creation_time", - "index.docker.io/prysmaticlabs/prysm-validator:latest": ":image_with_creation_time", - "index.docker.io/prysmaticlabs/prysm-validator:{DOCKER_TAG}": ":image_with_creation_time", - }, - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -go_image_debug( - name = "image_debug", - image = ":image", - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -container_bundle( - name = "image_bundle_debug", - images = { - "gcr.io/prysmaticlabs/prysm/validator:latest-debug": ":image_debug", - "gcr.io/prysmaticlabs/prysm/validator:{DOCKER_TAG}-debug": ":image_debug", - "index.docker.io/prysmaticlabs/prysm-validator:latest-debug": ":image_debug", - "index.docker.io/prysmaticlabs/prysm-validator:{DOCKER_TAG}-debug": ":image_debug", - }, - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - -docker_push( - name = "push_images_debug", - bundle = ":image_bundle_debug", - tags = ["manual"], - visibility = ["//validator:__pkg__"], -) - go_binary( name = "validator", embed = [":go_default_library"], @@ -124,10 +57,10 @@ go_test( ) prysm_image_upload( - name = "push_oci_image", + name = "push_images", binary = ":validator", entrypoint = ["/validator"], - repository = "gcr.io/prylabs-dev/prysm/validator", + repository = "gcr.io/prysmaticlabs/prysm/validator", symlinks = { # Backwards compatiability for images that depended on the old filepath. "/app/cmd/validator/validator": "/validator", diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index d33500812f..2180de8921 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,36 +1,26 @@ load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") -load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_entry", "passwd_file") -load("@io_bazel_rules_docker//container:container.bzl", "container_image") -load("//tools:build_settings.bzl", "base_image") +load("@rules_distroless//distroless:defs.bzl", "passwd") -################################################################################ -## Docker images as non-root user ## -################################################################################ - -# Create a passwd file with a root and nonroot user and uid. -passwd_entry( - name = "root_user", - gid = 0, - tags = ["manual"], - uid = 0, - username = "root", -) - -passwd_entry( - name = "nonroot_user", - info = "nonroot", - tags = ["manual"], - uid = 1001, - username = "nonroot", -) - -passwd_file( +passwd( name = "passwd", - entries = [ - ":root_user", - ":nonroot_user", + passwds = [ + dict( + gecos = ["root"], + gid = 0, + home = "/root", + shell = "/bin/bash", + uid = 0, + username = "root", + ), + dict( + gecos = ["nonroot"], + gid = 1001, + home = "/home/nonroot", + shell = "/bin/bash", + uid = 1001, + username = "nonroot", + ), ], - tags = ["manual"], ) # Create a tar file containing the created passwd file @@ -43,64 +33,6 @@ pkg_tar( visibility = ["//visibility:public"], ) -CC_DEFAULT_BASE = select({ - "@io_bazel_rules_docker//:debug": "@cc_debug_image_base_amd64//image", - "@io_bazel_rules_docker//:fastbuild": "@cc_image_base_amd64//image", - "@io_bazel_rules_docker//:optimized": "@cc_image_base_amd64//image", - "//conditions:default": "@cc_image_base_amd64//image", -}) - -GO_DEFAULT_BASE = select({ - "@io_bazel_rules_docker//:debug": "@go_debug_image_base_amd64//image", - "@io_bazel_rules_docker//:fastbuild": "@go_image_base_amd64//image", - "@io_bazel_rules_docker//:optimized": "@go_image_base_amd64//image", - "//conditions:default": "@go_image_base_amd64//image", -}) - -# Include it in our base image as a tar. -container_image( - name = "cc_image", - base = CC_DEFAULT_BASE, - tags = ["manual"], - tars = [":passwd_tar"], - user = "root", - visibility = ["//visibility:public"], -) - -container_image( - name = "go_image", - base = GO_DEFAULT_BASE, - tags = ["manual"], - tars = [":passwd_tar"], - user = "root", - visibility = ["//visibility:public"], -) - -base_image( - name = "base_image", - build_setting_default = "cc_image", - tags = ["manual"], -) - -config_setting( - name = "base_image_alpine", - flag_values = {"//tools:base_image": "alpine"}, -) - -config_setting( - name = "base_image_cc", - flag_values = {"//tools:base_image": "cc_image"}, -) - -container_image( - name = "alpine_cc_image", - base = "@alpine_cc_linux_amd64//image", - tags = ["manual"], - tars = [":passwd_tar"], - user = "root", - visibility = ["//visibility:public"], -) - # Create a bash tar layer for docker images. This allows docker images to have access to the "bash" # command and improves debugging abilities on the image. genrule( diff --git a/tools/bootnode/BUILD.bazel b/tools/bootnode/BUILD.bazel index 9922bf8bf3..9a165c5209 100644 --- a/tools/bootnode/BUILD.bazel +++ b/tools/bootnode/BUILD.bazel @@ -1,8 +1,6 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") 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:container.bzl", "container_bundle") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") +load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( name = "go_default_library", @@ -34,35 +32,12 @@ go_library( ], ) -go_image( - name = "image", - base = "//tools:cc_image", - binary = ":bootnode", - tags = ["manual"], - visibility = ["//visibility:private"], -) - go_binary( name = "bootnode", embed = [":go_default_library"], visibility = ["//visibility:public"], ) -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/bootnode:latest": ":image", - "gcr.io/prysmaticlabs/prysm/bootnode:{DOCKER_TAG}": ":image", - }, - tags = ["manual"], -) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], -) - go_test( name = "go_default_test", srcs = ["bootnode_test.go"], @@ -80,3 +55,15 @@ go_test( "@com_github_sirupsen_logrus//:go_default_library", ], ) + +prysm_image_upload( + name = "push_images", + binary = ":bootnode", + entrypoint = ["/bootnode"], + repository = "gcr.io/prysmaticlabs/prysm/bootnode", + symlinks = { + # Backwards compatibility for images that depended on the old filepath. + "/app/tools/bootnode/bootnode": "/bootnode", + }, + tags = ["manual"], +) diff --git a/tools/enr-calculator/BUILD.bazel b/tools/enr-calculator/BUILD.bazel index 85c591948c..0d01c6869c 100644 --- a/tools/enr-calculator/BUILD.bazel +++ b/tools/enr-calculator/BUILD.bazel @@ -1,8 +1,6 @@ load("@prysm//tools/go:def.bzl", "go_library") 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:container.bzl", "container_bundle") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") +load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( name = "go_default_library", @@ -26,25 +24,14 @@ go_binary( visibility = ["//visibility:public"], ) -go_image( - name = "image", - base = "//tools:go_image", - binary = "enr-calculator", - tags = ["manual"], - visibility = ["//visibility:private"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/enr-calculator:latest": ":image", - "gcr.io/prysmaticlabs/prysm/enr-calculator:{DOCKER_TAG}": ":image", +prysm_image_upload( + name = "push_images", + binary = ":enr-calculator", + entrypoint = ["/enr-calculator"], + repository = "gcr.io/prysmaticlabs/prysm/enr-calculator", + symlinks = { + # Backwards compatibility for images that depended on the old filepath. + "/app/tools/enr-calculator/enr-calculator": "/enr-calculator", }, tags = ["manual"], ) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], -) diff --git a/tools/eth1exporter/BUILD.bazel b/tools/eth1exporter/BUILD.bazel index ed404e66ee..9604d8b541 100644 --- a/tools/eth1exporter/BUILD.bazel +++ b/tools/eth1exporter/BUILD.bazel @@ -1,8 +1,6 @@ load("@prysm//tools/go:def.bzl", "go_library") 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:container.bzl", "container_bundle") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") +load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( name = "go_default_library", @@ -24,25 +22,14 @@ go_binary( visibility = ["//visibility:public"], ) -go_image( - name = "image", - base = "//tools:go_image", +prysm_image_upload( + name = "push_images", binary = ":eth1exporter", - tags = ["manual"], - visibility = ["//visibility:private"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/eth1monitor:latest": ":image", - "gcr.io/prysmaticlabs/prysm/eth1monitor:{DOCKER_TAG}": ":image", + entrypoint = ["/eth1exporter"], + repository = "gcr.io/prysmaticlabs/prysm/eth1monitor", + symlinks = { + # Backwards compatibility for images that depended on the old filepath. + "/app/tools/eth1exporter/eth1exporter": "/eth1exporter", }, tags = ["manual"], ) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], -) diff --git a/tools/go_image.bzl b/tools/go_image.bzl deleted file mode 100644 index a457f394d0..0000000000 --- a/tools/go_image.bzl +++ /dev/null @@ -1,59 +0,0 @@ -load("@io_bazel_rules_docker//container:providers.bzl", "ImageInfo") - -# Defines the debug transition implementation to enforce dbg mode. -def _debug_transition_impl(settings, attr): - return { - "//command_line_option:compilation_mode": "dbg", - } - -# Defines a starlark transition which enforces dbg compilation mode. -build_in_debug_mode = transition( - implementation = _debug_transition_impl, - inputs = [], - outputs = ["//command_line_option:compilation_mode"], -) - -def _alpine_transition_impl(settings, attr): - return { - "//tools:base_image": "alpine", - } - -use_alpine = transition( - implementation = _alpine_transition_impl, - inputs = [], - outputs = ["//tools:base_image"], -) - -# Defines a rule implementation that essentially returns all of the providers from the image attr. -def _go_image_debug_impl(ctx): - img = ctx.attr.image[0] - - return [ - img[ImageInfo], - img[OutputGroupInfo], - ] - -# Defines a rule that specifies a starlark transition to enforce debug compilation mode for debug -# images. -go_image_debug = rule( - implementation = _go_image_debug_impl, - attrs = { - "image": attr.label( - cfg = build_in_debug_mode, - executable = True, - ), - # Whitelist is required or bazel complains. - "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"), - }, -) -go_image_alpine = rule( - _go_image_debug_impl, - attrs = { - "image": attr.label( - cfg = use_alpine, - executable = True, - ), - # Whitelist is required or bazel complains. - "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"), - }, -) diff --git a/tools/http-request-sink/BUILD.bazel b/tools/http-request-sink/BUILD.bazel index fe5b1bae6c..a20b03f9c3 100644 --- a/tools/http-request-sink/BUILD.bazel +++ b/tools/http-request-sink/BUILD.bazel @@ -1,8 +1,6 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") 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:container.bzl", "container_bundle") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") +load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( name = "go_default_library", @@ -18,33 +16,6 @@ go_binary( visibility = ["//visibility:public"], ) -go_image( - name = "image", - base = select({ - "//tools:base_image_alpine": "//tools:alpine_cc_image", - "//tools:base_image_cc": "//tools:cc_image", - "//conditions:default": "//tools:cc_image", - }), - binary = ":http-request-sink", - tags = ["manual"], - visibility = ["//visibility:private"], -) - -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/http-request-sink:latest": ":image", - "gcr.io/prysmaticlabs/prysm/http-request-sink:{DOCKER_TAG}": ":image", - }, - tags = ["manual"], -) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], -) - go_test( name = "go_default_test", srcs = ["main_test.go"], @@ -54,3 +25,15 @@ go_test( "//testing/require:go_default_library", ], ) + +prysm_image_upload( + name = "push_images", + binary = ":http-request-sink", + entrypoint = ["/http-request-sink"], + repository = "gcr.io/prysmaticlabs/prysm/http-request-sink", + symlinks = { + # Backwards compatibility for images that depended on the old filepath. + "/app/tools/http-request-sink/http-request-sink": "/http-request-sink", + }, + tags = ["manual"], +) diff --git a/tools/pcli/BUILD.bazel b/tools/pcli/BUILD.bazel index fc7559762c..583d8d9e59 100644 --- a/tools/pcli/BUILD.bazel +++ b/tools/pcli/BUILD.bazel @@ -1,8 +1,6 @@ load("@prysm//tools/go:def.bzl", "go_library") 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:container.bzl", "container_bundle") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") +load("//tools:prysm_image.bzl", "prysm_image_upload") go_library( name = "go_default_library", @@ -25,31 +23,20 @@ go_library( ], ) -go_image( - name = "image", - base = "//tools:cc_image", - binary = ":pcli", - tags = ["manual"], - visibility = ["//visibility:private"], -) - go_binary( name = "pcli", embed = [":go_default_library"], visibility = ["//visibility:public"], ) -container_bundle( - name = "image_bundle", - images = { - "gcr.io/prysmaticlabs/prysm/pcli:latest": ":image", - "gcr.io/prysmaticlabs/prysm/pcli:{DOCKER_TAG}": ":image", +prysm_image_upload( + name = "push_images", + binary = ":pcli", + entrypoint = ["/pcli"], + repository = "gcr.io/prysmaticlabs/prysm/pcli", + symlinks = { + # Backwards compatibility for images that depended on the old filepath. + "/app/tools/pcli/pcli": "/pcli", }, tags = ["manual"], ) - -docker_push( - name = "push_images", - bundle = ":image_bundle", - tags = ["manual"], -)