Skip to content

java_image args broken in 0.23.0+#2124

Description

@joca-bt

馃悶 bug report

Affected Rule

java_image

(And possibly all other language rules.)

Is this a regression?

Yes.

0.22.0: worked fine
0.23.0: broken

Description

java_image args parameter broken in 0.23.0 (probably by #1957).

Previously, adding args to java_image would result in those args being propagated to the underlying java_binary rule and hence to the java application when starting it.

This behaviour was broken in 0.23.0 and these args are now being passed to docker.

0.22.0:

> bazel run :image
hello there!
[--stuff, --stuff]

0.23.0:

> bazel run :image
unknown flag: --stuff
See 'docker run --help'.

I am guessing this is happening with other language rules as well.

馃敩 Minimal Reproduction

BUILD:

load("@io_bazel_rules_docker//java:image.bzl", "java_image")

java_library(name = "lib", srcs = [ "Main.java" ])

java_binary(name = "bin", main_class = "demo.Main", runtime_deps = [ ":lib" ])

java_image(name = "image", base = "@java//image", main_class = "demo.Main", args = [ "--stuff" ], runtime_deps = [ ":lib" ])

Main.java:

package demo;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        System.out.println("hello there!");
        System.out.println(Arrays.toString(args));
    }
}

WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_docker",
    # sha256 = "59536e6ae64359b716ba9c46c39183403b01eabfbd57578e84398b4829ca499a",
    # strip_prefix = "rules_docker-0.22.0",
    # url = "https://github.com/bazelbuild/rules_docker/releases/download/v0.22.0/rules_docker-v0.22.0.tar.gz",
    sha256 = "85ffff62a4c22a74dbd98d05da6cf40f497344b3dbf1e1ab0a37ab2a1a6ca014",
    strip_prefix = "rules_docker-0.23.0",
    url = "https://github.com/bazelbuild/rules_docker/releases/download/v0.23.0/rules_docker-v0.23.0.tar.gz",
)

load("@io_bazel_rules_docker//repositories:repositories.bzl", "repositories")
repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", "deps")
deps()

load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
container_pull(name = "java", registry = "gcr.io", repository = "distroless/java", tag = "latest")

馃實 Your Environment

Operating System:

Linux 5.18.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 02 Jul 2022 21:03:06 +0000 x86_64 GNU/Linux

Output of bazel version:

Bazelisk version: v1.12.0
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334

Rules_docker version:

0.23.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days unless there is a comment indicating why not

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions