Skip to content

Commit

Permalink
Migrate from rules_docker to rules_oci. (#225)
Browse files Browse the repository at this point in the history
This is a prerequisite for migrating to Bzlmod.

Closes #194
  • Loading branch information
SanjayVas authored Dec 12, 2023
1 parent 52199fd commit 1537c55
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 117 deletions.
7 changes: 0 additions & 7 deletions BUILD.bazel

This file was deleted.

23 changes: 9 additions & 14 deletions build/common_jvm_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,21 @@
Adds external repos necessary for common-jvm.
"""

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
load(
"@com_google_googleapis//:repository_rules.bzl",
"switched_rules_by_language",
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies", "rules_pkg_register_toolchains")
load(
"@rules_proto//proto:repositories.bzl",
"rules_proto_dependencies",
"rules_proto_toolchains",
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)
load("//build/rules_kotlin:deps.bzl", "rules_kotlin_deps")
load("//build/io_bazel_rules_docker:base_images.bzl", "base_java_images")
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
load(
"@com_google_googleapis//:repository_rules.bzl",
"switched_rules_by_language",
)
load("@tink_java//:tink_java_deps.bzl", "tink_java_deps")
load("//build/rules_kotlin:deps.bzl", "rules_kotlin_deps")

# buildifier: disable=unnamed-macro
def common_jvm_deps():
Expand All @@ -45,9 +41,8 @@ def common_jvm_deps():
rules_proto_toolchains()
rules_jvm_external_deps()
grpc_deps()
container_repositories()
rules_kotlin_deps()
base_java_images()
rules_oci_dependencies()
switched_rules_by_language(
name = "com_google_googleapis_imports",
java = True,
Expand Down
16 changes: 8 additions & 8 deletions build/common_jvm_extra_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
Adds external repos necessary for common-jvm.
"""

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
load("@com_github_grpc_grpc_kotlin//:repositories.bzl", "grpc_kt_repositories")
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
load("@maven//:compat.bzl", "compat_repositories")
load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")
load(
"@io_bazel_rules_docker//java:image.bzl",
java_image_repositories = "repositories",
)
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
load("//build:grpc_extra_deps.bzl", "grpc_extra_deps")
load("//build/rules_oci:base_images.bzl", "base_java_images")

def common_jvm_extra_deps():
"""
Expand All @@ -34,7 +31,10 @@ def common_jvm_extra_deps():
rules_jvm_external_setup()
grpc_extra_deps()
compat_repositories()
container_deps()
java_image_repositories()
oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
)
base_java_images()
grpc_kt_repositories()
grpc_java_repositories()
22 changes: 12 additions & 10 deletions build/common_jvm_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ Adds external repos necessary for common-jvm.
"""

load("//build/bazel_skylib:repo.bzl", "bazel_skylib")
load("//build/rules_pkg:repo.bzl", "rules_pkg")
load("//build/protobuf:repo.bzl", "com_github_protocolbuffers_protobuf")
load("//build/rules_proto:repo.bzl", "rules_proto")
load("//build/platforms:repo.bzl", "platforms_repo")
load("//build/cloud_spanner_emulator:defs.bzl", "cloud_spanner_emulator_binaries")
load("//build/com_github_grpc_grpc:repo.bzl", "com_github_grpc_grpc")
load("//build/com_google_googleapis:repo.bzl", "com_google_googleapis")
load("//build/com_google_highwayhash:repo.bzl", "com_google_highwayhash")
load("//build/grpc_java:repo.bzl", "io_grpc_grpc_java")
load("//build/grpc_kotlin:repo.bzl", "com_github_grpc_grpc_kotlin")
load("//build/platforms:repo.bzl", "platforms_repo")
load("//build/protobuf:repo.bzl", "com_github_protocolbuffers_protobuf")
load("//build/rules_jvm_external:repo.bzl", "rules_jvm_external_repo")
load("//build/com_github_grpc_grpc:repo.bzl", "com_github_grpc_grpc")
load("//build/cloud_spanner_emulator:defs.bzl", "cloud_spanner_emulator_binaries")
load("//build/io_bazel_rules_docker:repo.bzl", "io_bazel_rules_docker")
load("//build/com_google_googleapis:repo.bzl", "com_google_googleapis")
load("//build/rules_kotlin:repo.bzl", "io_bazel_rules_kotlin")
load("//build/rules_multirun:repo.bzl", "rules_multirun")
load("//build/rules_oci:repo.bzl", "rules_oci")
load("//build/rules_pkg:repo.bzl", "rules_pkg")
load("//build/rules_proto:repo.bzl", "rules_proto")
load("//build/tink:repo.bzl", "tink_java")
load("//build/com_google_highwayhash:repo.bzl", "com_google_highwayhash")

def common_jvm_repositories():
"""
Expand All @@ -47,7 +48,8 @@ def common_jvm_repositories():
com_github_grpc_grpc_kotlin()
com_github_grpc_grpc()
cloud_spanner_emulator_binaries()
io_bazel_rules_docker()
rules_oci()
rules_multirun()
com_google_googleapis()
tink_java()
com_google_highwayhash()
46 changes: 0 additions & 46 deletions build/io_bazel_rules_docker/base_images.bzl

This file was deleted.

20 changes: 0 additions & 20 deletions build/io_bazel_rules_docker/repo.bzl

This file was deleted.

File renamed without changes.
25 changes: 25 additions & 0 deletions build/rules_multirun/repo.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 The Cross-Media Measurement Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Repository targets for rules_multirun."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def rules_multirun():
http_archive(
name = "rules_multirun",
sha256 = "9cd384e42b2da00104f0e18f25e66285aa21f64b573c667638a7a213206885ab",
strip_prefix = "rules_multirun-0.6.1",
url = "https://github.com/keith/rules_multirun/archive/refs/tags/0.6.1.tar.gz",
)
4 changes: 4 additions & 0 deletions build/rules_oci/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports_files([
"repositories_tmpl.txt",
"tags_tmpl.txt",
])
34 changes: 34 additions & 0 deletions build/rules_oci/base_images.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2020 The Cross-Media Measurement Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Build defs for base container images."""

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

def base_java_images():
"""Default base Java image targets."""

oci_pull(
name = "java_image_base",
# nonroot-amd64
digest = "sha256:781e3acb7934ce0fa5ceeb62ee1369248ab23ae26dce002138b3d0e5338d7486",
image = "gcr.io/distroless/java11-debian11",
)

oci_pull(
name = "java_debug_image_base",
# debug-nonroot-amd64
digest = "sha256:95749ff107e1a1e14a62709f305208973530764cdac02a0f7762295dba2c40d2",
image = "gcr.io/distroless/java11-debian11",
)
Loading

0 comments on commit 1537c55

Please sign in to comment.