-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oci_image
isn't setting architecture in the image config section
#117
Comments
Confirmed in my example that the image content was
package main
import (
"fmt"
"runtime"
)
func main() {
println(fmt.Sprintf("Hello, from %s/%s!", runtime.GOOS, runtime.GOARCH))
} Setup: sudo apt-get install qemu binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
REF=localhost:5000/examples/go/hello:latest_linux_aarch64
crane config "$REF" | jq '.architecture = "arm64"' | crane edit config "$REF" Tests: $ bazel run //examples/go/hello
INFO: Invocation ID: 5bdc5b4a-787a-4550-9e66-50e9d3d71a82
INFO: Analyzed target //examples/go/hello:hello (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //examples/go/hello:hello up-to-date:
bazel-bin/examples/go/hello/hello_/hello
INFO: Elapsed time: 0.145s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/examples/go/hello/hello_/hello
Hello, from linux/amd64!
$ docker run --rm --platform linux/arm64 localhost:5000/examples/go/hello:latest_linux_aarch64
Hello, from linux/arm64!
$ docker run --rm localhost:5000/examples/go/hello:latest_linux_x86_64
Hello, from linux/amd64! |
When you got a base image in your oci_image, oci_image automatically uses base image's arch and os. basically, This is a silent error we should handle better. either we say that the base image's |
The explanation sort of makes sense, but the devex doesn't. So I'm assuming the image example only works since it is statically linked and doesn't depend on anything else? AFAICT, I pointed to a multi-arch (Docker list style due to other issue since distroless went OCI in March). My expectation is that oci_image would use os and arch to transition the base dependency to that os/arch -- the tar content already was transitioned. Maybe oci_image should have platform parameter instead of os/architecture to do all transitions for me? I don't think I should have to multiple oci_pull single os/arch images? |
i agree about the DX point. since there is no transition on |
|
Ah, thanks! Was just about to ask the question for that -- I can see |
My updated target's pushed images work without modification now, although I haven't tried any binaries that are dynamically linked to distro libraries yet: [oci_image(
name = "hello_image_{}".format(platform),
architecture = "{}".format(attrs["arch"]),
base = "@distroless_base_linux_{}".format(attrs["arch"]),
entrypoint = ["/examples/go/hello/hello_/hello"],
env = {
"image_arch": "{}".format(attrs["arch"]),
"image_os": "linux",
},
os = "linux",
tars = [
":hello_tar_{}".format(platform),
],
) for platform, attrs in PLATFORMS.items()] Yes, some documentation about the multi-image labels that could be used from |
Sorry to resurrect this one. It doesn't seem that the information here is correct still or maybe i am just doing it wrong but I don't see those repos being created with the Follow up: these look to be the way you have to do this today. |
@michaelschuett-tomtom we still generate platform specific repos for multi platform images. |
Haven't had a chance to debug
image.sh.tpl
yet, but it doesn't seem thatarchitecture
is being set in the images while anenv
with the values to debug this issue does show up:WORKSPACE
BUILD.bazel
Note how
architecture
isamd64
, butEnv.image_arch
env was set toarm64
usingregctl image inspect localhost:5000/examples/go/hello:latest_linux_aarch64
:Using
bazel aquery
it can be seen that theplatform
is being properly passed for use bycrane
:Despite its actual contents, Docker will refuse to run it for
linux/arm64
:The text was updated successfully, but these errors were encountered: