Skip to content

Commit

Permalink
Add example of multi-arch oci_tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Aug 8, 2023
1 parent 40d3e19 commit e4db7bd
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
66 changes: 66 additions & 0 deletions examples/multi_arch_go/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_image_index", "oci_push", "oci_tarball")

go_library(
name = "lib",
srcs = ["main.go"],
importpath = "main",
)

go_binary(
name = "bin-x86_64",
embed = [":lib"],
goos = "linux",
goarch = "amd64",
)

pkg_tar(
name = "bin-x86_64_tar",
srcs = [":bin-x86_64"],
package_dir = "usr/local/bin",
)

go_binary(
name = "bin-arm64",
embed = [":lib"],
goos = "linux",
goarch = "arm64",
)

pkg_tar(
name = "bin-arm64_tar",
srcs = [":bin-arm64"],
package_dir = "usr/local/bin",
)

oci_image(
name = "image-x86_64",
base = "@ubuntu_linux_amd64",
entrypoint = ["/usr/local/bin/bin-x86_64"],
tars = [":bin-x86_64_tar"],
)

oci_image(
name = "image-arm64",
base = "@ubuntu_linux_arm64_v8",
entrypoint = ["/usr/local/bin/bin-arm64"],
tars = [":bin-arm64_tar"],
)

oci_image_index(
name = "image-multiarch",
images = [
":image-arm64",
":image-x86_64",
],
)

oci_tarball(
name = "image-multiarch-tar",
image = ":image-multiarch",
repo_tags = [
"docker.com/example:latest",
],
)
7 changes: 7 additions & 0 deletions examples/multi_arch_go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("yo")
}

0 comments on commit e4db7bd

Please sign in to comment.