-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature request for Bazel support: Support containers built with rules_oci #8886
Comments
Just to add some context to the issue, I'm having a similar problem on my setup, though it might not be directly correlated to Here is a condensed version of my apiVersion: skaffold/v4beta5
kind: Config
build:
platforms: ["linux/amd64"]
artifacts:
- image: backend
bazel:
target: //apps/backend:image.tar
profiles:
- name: local
manifests:
rawYaml:
- apps/**/deploy.local.yaml
- tools/k3d/manifests/*.yaml
build:
local:
push: true
deploy:
kubectl: {}
- name: prod
manifests:
rawYaml:
- apps/**/deploy.prod.yaml
deploy:
cloudrun:
projectid: <PROJECT>
region: <REGION> To specify the right Docker registry, I have wrapped Skaffold with a Makefile, and passing DOCKER_REPO_local := k3d-registry.local:9000
DOCKER_REPO_prod := <REGION>-docker.pkg.dev/<PROJECT>/docker
SKAFFOLD_ARGS :=
ifdef DOCKER_REPO_$(env)
SKAFFOLD_ARGS += --default-repo $(DOCKER_REPO_$(env))
endif
skaffold.run:
skaffold run -p $(env) $(SKAFFOLD_ARGS) Hopefully I can remove this if/when #8920 is closed. What I have observed:
I suspect that the reason for 2. is that Skaffold inspects the Kubernetes context of the local configuration, and extracts some info from it (e.g. skaffold/pkg/skaffold/runner/runcontext/context.go Lines 430 to 438 in 637fe0d
skaffold/pkg/skaffold/config/util.go Lines 367 to 397 in 88e1c17
Which then gets used during the skaffold/cmd/skaffold/app/cmd/run.go Lines 45 to 49 in 88e1c17
|
oci_tarball(
name = "ccc.tar",
image = "@hello//:hello",
repo_tags = ["bazel:ccc", "hello:latest"],
) other tags are optional. we're currently a bit understaffed, the official support for oci rule may not be prioritized. |
Is there a reason it would be non-deterministic, or dependent on some aspect of docker state? I thought had it working with this workaround, then it stopped working. Using relative targets ":foo" instead of "//abs/path/to:foo" seems to get it to work again. I am wondering if that's because it avoids skaffold/pkg/skaffold/build/bazel/build.go Line 163 in d019fdd
|
Confirming that the workaround of putting the target on the same level as skaffold.yaml and using the relative target results in a successful build. (Note: it does not work if the target is Example below
|
Not sure why this part of code was implemented in this way, I don't know much about bazel, but it looks like that with the original docker build rule, there is no dedicated place to specify image tag when bazel builds a image tarball, it deduces image name/tag from the target name and wrap it in the tarball, when the tarball is loaded to a docker daemon the tag is used, skaffold is kind doing something similar to construct the tag, and then get the imageID with the tag from docker daemon. For oci_tarball rule, you can specify your tag in Also, this feature request has been prioritized, should be available after one or two releases. |
rules_oci is a new container builder for Bazel. Compared to rules_docker, it is under active development and recently released 1.0.
Instead of one container_image rule that also produces a .tar target for docker, rules_oci separates two rules: oci_image and oci_tarball.
Despite the fact that docker (or in my case, colima) can load and run the output of rules_oci, when using skaffold, something breaks with the following error:
build [hello-image] failed: tagging the image: Error parsing reference: "" is not a valid repository/tag: invalid reference format
See longer version below, and attached small workspace. rules_oci_demo.tar.gzThe text was updated successfully, but these errors were encountered: