-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of multi-arch oci_tarball
- Loading branch information
1 parent
40d3e19
commit e4db7bd
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("yo") | ||
} |