summaryrefslogtreecommitdiffhomepage
path: root/images
diff options
context:
space:
mode:
authorIan Lewis <ianlewis@google.com>2020-10-22 21:21:16 -0700
committergVisor bot <gvisor-bot@google.com>2020-10-22 21:22:54 -0700
commitcc772f3d54d46b65c663c8cf7812103df31f17d3 (patch)
tree8ee2b193e6910a0e93698b008061249b2e0a59da /images
parentc1a6ba06ab402c08e3300abd9403026c690dc168 (diff)
Add a platform portability blog post
Also fixes the docker_image bazel rule, and website-server make target. Fixes #3273 PiperOrigin-RevId: 338606668
Diffstat (limited to 'images')
-rw-r--r--images/defs.bzl17
1 files changed, 10 insertions, 7 deletions
diff --git a/images/defs.bzl b/images/defs.bzl
index 61d7bbf73..c1f96e312 100644
--- a/images/defs.bzl
+++ b/images/defs.bzl
@@ -2,30 +2,33 @@
def _docker_image_impl(ctx):
importer = ctx.actions.declare_file(ctx.label.name)
+
importer_content = [
"#!/bin/bash",
"set -euo pipefail",
+ "source_file='%s'" % ctx.file.data.path,
+ "if [[ ! -f \"$source_file\" ]]; then",
+ " source_file='%s'" % ctx.file.data.short_path,
+ "fi",
"exec docker import " + " ".join([
"-c '%s'" % attr
for attr in ctx.attr.statements
- ]) + " " + " ".join([
- "'%s'" % f.path
- for f in ctx.files.data
- ]) + " $1",
+ ]) + " \"$source_file\" $1",
"",
]
+
ctx.actions.write(importer, "\n".join(importer_content), is_executable = True)
return [DefaultInfo(
- runfiles = ctx.runfiles(ctx.files.data),
+ runfiles = ctx.runfiles([ctx.file.data]),
executable = importer,
)]
docker_image = rule(
implementation = _docker_image_impl,
- doc = "Tool to load a Docker image; takes a single parameter (image name).",
+ doc = "Tool to import a Docker image; takes a single parameter (image name).",
attrs = {
"statements": attr.string_list(doc = "Extra Dockerfile directives."),
- "data": attr.label_list(doc = "All image data."),
+ "data": attr.label(doc = "Image filesystem tarball", allow_single_file = [".tgz", ".tar.gz"]),
},
executable = True,
)