You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm trying to build my docker images from my Go project with rules_oci. I tried following your guide, but I'm getting an error when attempting to load the tarball into docker.
My tarball target has the repotags set:
go_binary(
name = "phono",
embed = [":phono_lib"],
visibility = ["//visibility:public"],
)
pkg_tar(
name = "phono_tarball",
srcs = [":phono"],
)
oci_image(
name = "phono_image",
architecture = select({
"@platforms//cpu:arm64": "arm64",
"@platforms//cpu:x86_64": "amd64",
}),
base = "@distroless_base",
tars = [":phono_tarball"],
entrypoint = ["/app"],
os = "linux",
)
oci_tarball(
name = "phono_image_tarball",
image = ":phono_image",
repotags = ["phono:latest"],
)
But I'm getting this error when running:
$ docker load --input /private/var/tmp/_bazel_logan/6935840e8ee73f156f0328fbaa27d52a/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/apps/phono/phono_image_tarball/tarball.tar
json: cannot unmarshal string into Go struct field manifestItem.RepoTags of type []string
Note that I'm using a bazel symlink prefix in my .bazelrc:
build --symlink_prefix=.bazel/
So I had to use a shell script to construct the full path to the tar:
#!/bin/zsh
# Get the file path of the image tarball:
OCI_IMAGE_TARBALL_RELATIVE_FILE_PATH=$(bazel cquery --output=files $1)
# Trim off the bazel-out prefix:
OCI_IMAGE_TARBALL_RELATIVE_FILE_PATH=${OCI_IMAGE_TARBALL_RELATIVE_FILE_PATH#"bazel-out"}
# Get the path to the bazel-out directory at the destination of our symlink:
BAZEL_OUT_DIR_PATH=$(readlink -f .bazel/out)
# Concatenate the two together to get an absolute path to the image tarball:
OCI_IMAGE_TARBALL_ABSOLUTE_FILE_PATH=$BAZEL_OUT_DIR_PATH$OCI_IMAGE_TARBALL_RELATIVE_FILE_PATH
# Load the image into docker:
docker load --input $OCI_IMAGE_TARBALL_ABSOLUTE_FILE_PATH
I was able to work around the issue by using docker import instead and providing the tag manually but this is less than ideal:
Hi! I'm trying to build my docker images from my Go project with rules_oci. I tried following your guide, but I'm getting an error when attempting to load the tarball into docker.
My tarball target has the repotags set:
But I'm getting this error when running:
Note that I'm using a bazel symlink prefix in my .bazelrc:
So I had to use a shell script to construct the full path to the tar:
I was able to work around the issue by using docker import instead and providing the tag manually but this is less than ideal:
Do you have any suggestions?
The text was updated successfully, but these errors were encountered: