Skip to content

Commit

Permalink
add oci push
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-bee committed Oct 14, 2024
1 parent f058c4d commit 81ba77d
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 19 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use_repo(go_deps, "com_github_azure_azure_sdk_for_go_sdk_azcore", "com_github_az

bazel_dep(name = "aspect_bazel_lib", version = "2.8.0")
bazel_dep(name = "rules_oci", version = "1.7.2")
bazel_dep(name = "rules_pkg", version = "0.7.0")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "container_structure_test", version = "1.15.0")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
Expand Down
151 changes: 149 additions & 2 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 37 additions & 16 deletions core-image/BUILD
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@container_structure_test//:defs.bzl", "container_structure_test")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball", "oci_push")
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

# Put app go_binary into a tar layer.
pkg_tar(
name = "app_layer",
srcs = ["//onyx/cmd/cli:onyx"],
# If the binary depends on RUNFILES, uncomment the attribute below.
# include_runfiles = True
#include_runfiles = True
)

# Prove that the application is at the path we expect in that tar.
Expand All @@ -36,24 +37,44 @@ platform_transition_filegroup(
}),
)

# Use the value of --embed_label under --stamp, otherwise use a deterministic constant
# value to ensure cache hits for actions that depend on this.
expand_template(
name = "stamped",
out = "_stamped.tags.txt",
stamp_substitutions = {"0.0.0": "{{BUILD_EMBED_LABEL}}"},
template = [
"0.0.0",
"nightly",
],
)

oci_push(
name = "push-image",
image = ":transitioned_image",
repository = "ghcr.io/b-s-f/yaku/core-image-test",
remote_tags = ":stamped",
)

# $ bazel build //core-image:tarball
# $ docker load --input $(bazel cquery --output=files //core-image:tarball)
# $ docker run --rm gcr.io/example:latest
# $ docker run --rm gcr.io/example:foo
# string(
# - "Hello World",
# + "Hello Go",
# )
oci_tarball(
name = "tarball",
# Use the image built for the exec platform rather than the target platform
image = ":image",
repo_tags = ["gcr.io/example:latest"],
)

container_structure_test(
name = "test",
configs = ["test.yaml"],
# Use the image built for the exec platform rather than the target platform
image = ":image",
tags = ["requires-docker"],
)
#oci_tarball(
# name = "tarball",
# # Use the image built for the exec platform rather than the target platform
# image = ":transitioned_image",
# repo_tags = ["bar/example:foo"],
#)

#container_structure_test(
# name = "test",
# configs = ["test.yaml"],
# # Use the image built for the exec platform rather than the target platform
# image = ":image",
# tags = ["requires-docker"],
#)

0 comments on commit 81ba77d

Please sign in to comment.