Skip to content
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

Document how to use rules_distroless with BZLMOD #37

Open
Sineaggi opened this issue Apr 17, 2024 · 9 comments
Open

Document how to use rules_distroless with BZLMOD #37

Sineaggi opened this issue Apr 17, 2024 · 9 comments
Labels
feature request New feature or request

Comments

@Sineaggi
Copy link

All the docs I've seen around using deb_index say

WORKSPACE example;

load("@rules_distroless//apt:index.bzl", "deb_index")

deb_index(
    name = "bullseye",
    # For the initial setup, the lockfile attribute can be omitted  and generated by running
    #    bazel run @bullseye//:lock
    # This will generate the lock.json file next to the manifest file by replacing `.yaml` with `.lock.json`
    lock = "//examples/apt:bullseye.lock.json",
    manifest = "//examples/apt:bullseye.yaml",
)

load("@bullseye//:packages.bzl", "bullseye_packages")
bullseye_packages()

BZLMOD example;

# TODO: support BZLMOD

Has BZLMOD support been added and we just need to update docs, or is BZLMOD support missing?

@Sineaggi
Copy link
Author

Sineaggi commented Apr 17, 2024

I tried adding load("@rules_distroless//apt:index.bzl", "deb_index") to WORKSPACE.bzlmod crashes bazel info in 7.1.1 with

java.lang.NullPointerException: Cannot invoke "java.lang.Throwable.getMessage()" because "cause" is null
	at com.google.devtools.build.lib.analysis.config.InvalidConfigurationException.<init>(InvalidConfigurationException.java:53)
	at com.google.devtools.build.lib.skyframe.SkyframeExecutor.createBuildConfigurationKey(SkyframeExecutor.java:1795)
	at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfiguration(SkyframeExecutor.java:1734)
	at com.google.devtools.build.lib.runtime.commands.InfoCommand.lambda$exec$0(InfoCommand.java:158)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:181)
	at com.google.devtools.build.lib.runtime.commands.InfoCommand.exec(InfoCommand.java:215)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:664)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:644)
	at io.grpc.Context$1.run(Context.java:566)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

same stacktrace as in bazelbuild/bazel#21289

@thesayyn
Copy link
Collaborator

thesayyn commented Apr 29, 2024

Bzlmod is not supported yet, PRs welcome!

@thesayyn thesayyn added the feature request New feature or request label Apr 29, 2024
@Sineaggi
Copy link
Author

@thesayyn what does adding bzlmod support usually entail? Like I said, I tried pulling deb_index out into an extension and got the NPE you see above.

@thesayyn
Copy link
Collaborator

I am not sure what would be cause of that, but in order to support we'd need to have an extension which parses the lockfile expands to multiple repositories, one per package, another hub repo where aliases are defined.

@aj185259
Copy link

Looks like this was fixed with #50!

Feel like cutting a release?

@APLmath
Copy link

APLmath commented Jul 14, 2024

I'm super excited about using rules_distroless with Bzlmod, but it looks like the latest 0.3.4 release is failing some checks in the official Bazel Registry: bazelbuild/bazel-central-registry#2323

Looks like it's not working in macOS? https://buildkite.com/bazel/bcr-presubmit/builds/6406

@jjmaestro
Copy link
Contributor

Yeah, 0.3.4 doesn't exist for MacOS and thus Bzlmod doesn't work for me either :-/

ERROR: Error computing the main repository mapping: module not found in registries: rules_distroless@0.3.4

For the time being, I got it to work with an override pointing to the hash of the 0.3.4 release:

bazel_dep(name = "rules_distroless", version = "0.3.3")

# NOTE:
# Even though rules_distroless PR#50 enabled Bzlmod and it was released in
# 0.3.4, the release failed for MacOS, so this git_override is needed until
# a new release / fix is available.
# See: https://github.com/GoogleContainerTools/rules_distroless/issues/37#issuecomment-2227494145

RULES_DISTROLESS_0_3_4_RELEASE = "9da4ee521ab077fbd37744cb1acdad9e0f44b349"
git_override(
    module_name = "rules_distroless",
    commit = RULES_DISTROLESS_0_3_4_RELEASE,
    remote = "https://github.com/GoogleContainerTools/rules_distroless",
)

@thesayyn
Copy link
Collaborator

thesayyn commented Aug 8, 2024

#70 should make bzlmod on par with workspace rules.

@jjmaestro
Copy link
Contributor

@thesayyn cool, thanks!! Also, will there be a release pushed to Bazel Central Registry?

The latest version pushed to the registry seems to be v0.3.3 three months ago, and 0.3.4 to 0.3.6 are all Github releases but aren't pushed to the registry, so we have to patch with git_override. It's not too bad but I think having a release that's easy to use would be great :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants