Skip to content

Commit

Permalink
Init rules_oci
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng committed Sep 26, 2024
1 parent d83c117 commit e2be71b
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 34 deletions.
20 changes: 20 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module(name = "buildbuddy")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "toolchains_musl", version = "0.1.15")
bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5")
single_version_override(
Expand Down Expand Up @@ -453,3 +454,22 @@ http_archive(
"https://github.com/sluongng/nogo-analyzer/archive/refs/tags/v0.0.2.tar.gz",
],
)

bazel_dep(name = "rules_oci", version = "2.0.0")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "buildbuddy_go_oci_image_base",
digest = "sha256:388145607c79313a1e49b783a7ee71e4ef3df31d87c45adb46bfb9b257b643d1",
image = "gcr.io/distroless/cc-debian12",
)
oci.pull(
name = "bazel_oci_image_base",
digest = "sha256:8bb82ccf73085b71159ce05d2cc6030cbaa927b403c04774f0b22f37ab4fd78a",
image = "gcr.io/distroless/java17-debian12",
)
use_repo(
oci,
"bazel_oci_image_base",
"buildbuddy_go_oci_image_base",
)
69 changes: 52 additions & 17 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

http_archive(
name = "rules_pkg",
integrity = "sha256-0gyVGWDtd8t7NBwqWUiFNOSU1a0dMMSBjHNtV3cqn+8=",
url = "https://github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz",
)

# Proto rules

http_archive(
Expand Down Expand Up @@ -344,6 +350,21 @@ k8s_defaults(
kind = "deployment",
)

http_archive(
name = "rules_oci",
sha256 = "d007e6c96eb62c88397b68f329e4ca56e0cfe31204a2c54b0cb17819f89f83c8",
strip_prefix = "rules_oci-2.0.0",
url = "https://github.com/bazel-contrib/rules_oci/releases/download/v2.0.0/rules_oci-v2.0.0.tar.gz",
)

load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")

rules_oci_dependencies()

load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")

oci_register_toolchains(name = "oci")

load("@io_bazel_rules_docker//contrib:dockerfile_build.bzl", "dockerfile_image")

dockerfile_image(
Expand All @@ -370,23 +391,6 @@ dockerfile_image(
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_docker//container:container.bzl", "container_pull")

container_pull(
name = "buildbuddy_go_image_base",
digest = "sha256:388145607c79313a1e49b783a7ee71e4ef3df31d87c45adb46bfb9b257b643d1",
registry = "gcr.io",
repository = "distroless/cc-debian12",
)

# Base image that can be used to build images that are capable of running the Bazel binary.
container_pull(
name = "bazel_image_base",
digest = "sha256:8bb82ccf73085b71159ce05d2cc6030cbaa927b403c04774f0b22f37ab4fd78a",
registry = "gcr.io",
repository = "distroless/java17-debian12",
)

dockerfile_image(
name = "rbe-ubuntu20-04_image",
dockerfile = "//dockerfiles/rbe-ubuntu20-04:Dockerfile",
Expand Down Expand Up @@ -415,6 +419,37 @@ dockerfile_image(
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_docker//container:container.bzl", "container_pull")

container_pull(
name = "buildbuddy_go_image_base",
digest = "sha256:388145607c79313a1e49b783a7ee71e4ef3df31d87c45adb46bfb9b257b643d1",
registry = "gcr.io",
repository = "distroless/cc-debian12",
)

# Base image that can be used to build images that are capable of running the Bazel binary.
container_pull(
name = "bazel_image_base",
digest = "sha256:8bb82ccf73085b71159ce05d2cc6030cbaa927b403c04774f0b22f37ab4fd78a",
registry = "gcr.io",
repository = "distroless/java17-debian12",
)

load("@rules_oci//oci:pull.bzl", "oci_pull")

oci_pull(
name = "buildbuddy_go_oci_image_base",
digest = "sha256:388145607c79313a1e49b783a7ee71e4ef3df31d87c45adb46bfb9b257b643d1",
image = "gcr.io/distroless/cc-debian12",
)

oci_pull(
name = "bazel_oci_image_base",
digest = "sha256:8bb82ccf73085b71159ce05d2cc6030cbaa927b403c04774f0b22f37ab4fd78a",
image = "gcr.io/distroless/java17-debian12",
)

# BuildBuddy Toolchain
# Keep up-to-date with docs/rbe-setup.md and docs/rbe-github-actions.md
http_archive(
Expand Down
34 changes: 17 additions & 17 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,6 @@ dockerfile_image(
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_docker//container:container.bzl", "container_pull")

container_pull(
name = "buildbuddy_go_image_base",
digest = "sha256:3172df37ef8caa768ce74ebbc7f0e2b6a2641d3b35d18659d36f3815e30fe620",
registry = "gcr.io",
repository = "distroless/cc-debian11",
)

# Base image that can be used to build images that are capable of running the Bazel binary.
container_pull(
name = "bazel_image_base",
digest = "sha256:ab0c5fbe16bc01c03eb081a5724ba618110cbd24940ab123a8dbee0382a4c175",
registry = "gcr.io",
repository = "distroless/java11-debian11",
)

dockerfile_image(
name = "rbe-ubuntu20-04_image",
dockerfile = "//dockerfiles/rbe-ubuntu20-04:Dockerfile",
Expand Down Expand Up @@ -150,6 +133,23 @@ dockerfile_image(
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_docker//container:container.bzl", "container_pull")

container_pull(
name = "buildbuddy_go_image_base",
digest = "sha256:3172df37ef8caa768ce74ebbc7f0e2b6a2641d3b35d18659d36f3815e30fe620",
registry = "gcr.io",
repository = "distroless/cc-debian11",
)

# Base image that can be used to build images that are capable of running the Bazel binary.
container_pull(
name = "bazel_image_base",
digest = "sha256:ab0c5fbe16bc01c03eb081a5724ba618110cbd24940ab123a8dbee0382a4c175",
registry = "gcr.io",
repository = "distroless/java11-debian11",
)

# BuildBuddy Toolchain
# Keep up-to-date with docs/rbe-setup.md and docs/rbe-github-actions.md
http_archive(
Expand Down
45 changes: 45 additions & 0 deletions tools/probers/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

container_image(
name = "probers_image",
Expand Down Expand Up @@ -29,3 +31,46 @@ container_push(
tag_file = "//deployment:image_tag_file",
tags = ["manual"], # Don't include this target in wildcard patterns
)

pkg_tar(
name = "files_tar",
srcs = [
"//tools/probers/bazelrbe",
"//tools/probers/workflow",
"@cloudprober",
],
)

oci_image(
name = "probers_oci_image",
base = "@bazel_oci_image_base",
entrypoint = [
"/cloudprober",
"--logtostderr",
],
target_compatible_with = [
"@platforms//os:linux",
# TODO: use a multi-arch base image to support arm64
"@platforms//cpu:x86_64",
],
tars = [
"//server/util/bazel:bazel_binaries_tar",
":files_tar",
],
visibility = ["//visibility:public"],
)

# TODO: rules OCI only support tag file names with the ".txt" extension.
genrule(
name = "oci_tag",
srcs = ["//deployment:image_tag_file"],
outs = ["oci_tag.txt"],
cmd = "cp $(location //deployment:image_tag_file) $@",
)

oci_push(
name = "push_probers_oci_image",
image = ":probers_oci_image",
remote_tags = ":oci_tag.txt",
repository = "gcr.io/flame-build/probers-oci",
)

0 comments on commit e2be71b

Please sign in to comment.