Skip to content

Commit 3752405

Browse files
committed
Use rules distroless to build example container
This introduces the rules_distroless-based `oak_containers/app_base`, and uses it to build the hello world example runtime bundle. Bug: b/491930890 Change-Id: I838bba2e226a712bebe6b70ab9a43b886a6a6964
1 parent 2007e07 commit 3752405

15 files changed

Lines changed: 1027 additions & 47 deletions

File tree

MODULE.bazel

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ bazel_dep(name = "rules_nixpkgs_core", version = "0.13.0")
142142
nix_repos = use_extension("//bazel/nix:extensions.bzl", "nix_repos", dev_dependency = True)
143143
use_repo(nix_repos, "nix_linux_kernel", "nix_vanilla_linux_kernel")
144144

145-
##### OCI
145+
##### Container Management
146146

147147
bazel_dep(name = "rules_oci", version = "2.2.6")
148148

@@ -170,6 +170,16 @@ use_repo(oak_toolchains, "oak_cc_toolchain_sysroot", "umoci")
170170
# On macOS, uses system-installed umoci (via Nix). See umoci_toolchain.bzl.
171171
register_toolchains("@umoci//:umoci_toolchain", "@umoci//:umoci_toolchain_darwin")
172172

173+
bazel_dep(name = "rules_distroless", version = "0.6.1")
174+
175+
apt = use_extension("@rules_distroless//apt:extensions.bzl", "apt")
176+
apt.install(
177+
name = "oak_containers_app_base",
178+
lock = "//oak_containers/app_base:app_base.lock.json",
179+
manifest = "//oak_containers/app_base:app_base.yaml",
180+
)
181+
use_repo(apt, "oak_containers_app_base")
182+
173183
# Run clang-tidy on C++ code with the following command:
174184
# bazel build //cc/... \
175185
# --aspects=@bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect \

MODULE.bazel.lock

Lines changed: 87 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cc/containers/hello_world_enclave_app/BUILD

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
1818
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1919
load("@rules_cc//cc:cc_test.bzl", "cc_test")
20-
load("@rules_oci//oci:defs.bzl", "oci_image")
21-
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
22-
load("//bazel:defs.bzl", "oci_runtime_bundle")
20+
load("//oak_containers/app_base:defs.bzl", "app_bundle")
2321

2422
package(licenses = ["notice"])
2523

@@ -87,22 +85,9 @@ cc_binary(
8785
],
8886
)
8987

90-
pkg_tar(
91-
name = "tar",
92-
srcs = [":main"],
93-
package_dir = "/usr/local/bin",
94-
)
95-
96-
oci_image(
97-
name = "image",
98-
base = "@distroless_cc_debian12_linux_amd64",
99-
entrypoint = ["/usr/local/bin/main"],
100-
tars = [":tar"],
101-
)
102-
103-
oci_runtime_bundle(
88+
app_bundle(
10489
name = "bundle",
105-
image = ":image",
90+
binary = ":main",
10691
visibility = [
10792
"//oak_containers/examples/hello_world/host_app:__subpackages__",
10893
],

0 commit comments

Comments
 (0)