summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--images/defs.bzl31
-rw-r--r--website/BUILD12
-rwxr-xr-xwebsite/import.sh27
4 files changed, 40 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index 4f7db7d82..cdfcc63b3 100644
--- a/Makefile
+++ b/Makefile
@@ -94,9 +94,9 @@ endef
rebuild-...: ## Rebuild the given image. Also may use 'rebuild-all-images'.
$(eval $(call images,rebuild))
push-...: ## Push the given image. Also may use 'push-all-images'.
-$(eval $(call images,pull))
-pull-...: ## Pull the given image. Also may use 'pull-all-images'.
$(eval $(call images,push))
+pull-...: ## Pull the given image. Also may use 'pull-all-images'.
+$(eval $(call images,pull))
load-...: ## Load (pull or rebuild) the given image. Also may use 'load-all-images'.
$(eval $(call images,load))
list-images: ## List all available images.
@@ -258,7 +258,7 @@ WEBSITE_PROJECT := gvisordev
WEBSITE_REGION := us-central1
website-build: load-jekyll ## Build the site image locally.
- @$(call submake,run TARGETS="//website:website")
+ @$(call submake,run TARGETS="//website:website" ARGS="$(WEBSITE_IMAGE)")
.PHONY: website-build
website-server: website-build ## Run a local server for development.
@@ -266,7 +266,7 @@ website-server: website-build ## Run a local server for development.
.PHONY: website-server
website-push: website-build ## Push a new image and update the service.
- @docker tag gvisor.dev/images/website $(WEBSITE_IMAGE) && docker push $(WEBSITE_IMAGE)
+ @docker push $(WEBSITE_IMAGE)
.PHONY: website-push
website-deploy: website-push ## Deploy a new version of the website.
diff --git a/images/defs.bzl b/images/defs.bzl
new file mode 100644
index 000000000..61d7bbf73
--- /dev/null
+++ b/images/defs.bzl
@@ -0,0 +1,31 @@
+"""Helpers for Docker image generation."""
+
+def _docker_image_impl(ctx):
+ importer = ctx.actions.declare_file(ctx.label.name)
+ importer_content = [
+ "#!/bin/bash",
+ "set -euo pipefail",
+ "exec docker import " + " ".join([
+ "-c '%s'" % attr
+ for attr in ctx.attr.statements
+ ]) + " " + " ".join([
+ "'%s'" % f.path
+ for f in ctx.files.data
+ ]) + " $1",
+ "",
+ ]
+ ctx.actions.write(importer, "\n".join(importer_content), is_executable = True)
+ return [DefaultInfo(
+ runfiles = ctx.runfiles(ctx.files.data),
+ executable = importer,
+ )]
+
+docker_image = rule(
+ implementation = _docker_image_impl,
+ doc = "Tool to load 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."),
+ },
+ executable = True,
+)
diff --git a/website/BUILD b/website/BUILD
index 6d92d9103..f3642b903 100644
--- a/website/BUILD
+++ b/website/BUILD
@@ -1,17 +1,15 @@
load("//tools:defs.bzl", "bzl_library", "pkg_tar")
load("//website:defs.bzl", "doc", "docs")
+load("//images:defs.bzl", "docker_image")
package(licenses = ["notice"])
-# website is the full container image. Note that this actually just collects
-# other dependendcies and runs Docker locally to import and tag the image.
-sh_binary(
+docker_image(
name = "website",
- srcs = ["import.sh"],
data = [":files"],
- tags = [
- "local",
- "manual",
+ statements = [
+ "EXPOSE 8080/tcp",
+ 'ENTRYPOINT ["/server"]',
],
)
diff --git a/website/import.sh b/website/import.sh
deleted file mode 100755
index e1350e83d..000000000
--- a/website/import.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-# Copyright 2018 The gVisor Authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -xeuo pipefail
-
-if [[ -d $0.runfiles ]]; then
- cd $0.runfiles
-fi
-
-exec docker import \
- -c "EXPOSE 8080/tcp" \
- -c "ENTRYPOINT [\"/server\"]" \
- $(find . -name files.tgz) \
- gvisor.dev/images/website