bazel-contrib / rules_oci

Bazel rules for building OCI containers
Apache License 2.0
280 stars 146 forks source link

rules_oci does not work on linux arm64 hosts due to jq dependency #253

Closed chancila closed 4 months ago

chancila commented 1 year ago
While resolving toolchains for target //bin/services/external_proxy:image: No matching toolchains found for types @aspect_bazel_lib//lib:jq_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@aspect_bazel_lib//lib:jq_toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.

//bin/services/external_proxy:image being a oci_image target

if this is a known issue perhaps stating compatible architectures might be handy

chancila commented 1 year ago

I was able to work around this issue by building my own jq arm64 binary and registering a toolchain within my workspace locally:

on a mac arm64 host:

docker run --rm -it ubuntu:18.04
apt update
apt upgrade
apt install git build-essential make libtool autoconf
git clone https://github.com/jqlang/jq
git submodule update --init --recursive
autoreconf -fi
./configure --with-oniguruma=builtin
make -j8
load("@aspect_bazel_lib//lib/private:jq_toolchain.bzl", "jq_toolchain")

jq_toolchain(
    name = "jq_linux_arm64_tools",
    bin = ":jq", # binary copied from above result
)

toolchain(
    name = "jq_linux_arm64_toolchain",
    exec_compatible_with = [
        "@platforms//os:linux",
        "@platforms//cpu:arm64",
    ],
    toolchain = ":jq_linux_arm64_tools",
    toolchain_type = "@aspect_bazel_lib//lib:jq_toolchain_type",
)
malt3 commented 1 year ago

FYI: This can soon be resolved using yq since stamping support is coming.

archen commented 1 year ago

if anyone is looking for a quick patch-around, this works for my own usecases but I make no guarantees that it works with all: https://github.com/archen/rules_oci/pull/1

michaeljs1990 commented 1 year ago

Tested out your above patch and although it looks like it might break something else based on the tests it did let me keep developing on my linux/arm64 machine. I don't think I will ever purchase another arm machine 😞

archen commented 1 year ago

@michaeljs1990 yeah I haven't had time to replace all of the filtration in the image.sh.tpl with yq-compat. It's funny... ARM hasn't been as painful as I thought it would be, but I sure am glad I'm using bazel to compile tools from code as needed for my dev corps instead of relying on prebuilds.

thesayyn commented 1 year ago

See https://github.com/bazel-contrib/rules_oci/pull/337#issuecomment-1718621054

thesayyn commented 11 months ago

Will be fixed by #386

hunshcn commented 5 months ago

When will we upgrade to bazel-lib 2.0? Is there a definite schedule? This hinders some tests (all my personal machines are arm64, linux/mac).

thesayyn commented 4 months ago

fixed by https://github.com/bazel-contrib/rules_oci/pull/386

When will we upgrade to bazel-lib 2.0

That will happen with the 2.x version of rules_oci, which we are already landing PRs to.