github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/website/BUILD (about)

     1  load("//tools:defs.bzl", "bzl_library", "pkg_tar")
     2  load("//website:defs.bzl", "doc", "docs")
     3  load("//images:defs.bzl", "docker_image")
     4  
     5  package(licenses = ["notice"])
     6  
     7  docker_image(
     8      name = "website",
     9      data = ":files",
    10      statements = [
    11          "EXPOSE 8080/tcp",
    12          'ENTRYPOINT ["/server"]',
    13      ],
    14      tags = [
    15          "local",
    16          "manual",
    17          "no-sandbox",
    18      ],
    19  )
    20  
    21  # files is the full file system of the generated container.
    22  #
    23  # It must collect the all tarballs (produced by the rules below), and run it
    24  # through the Dockerfile to generate the site. Note that this checks all links,
    25  # and therefore requires all static content to be present as well.
    26  #
    27  # Note that this rule violates most aspects of hermetic builds. However, this
    28  # works much more reliably than depending on the container_image rules from
    29  # bazel itself, which are convoluted and seem to have a hard time even finding
    30  # the toolchain.
    31  genrule(
    32      name = "files",
    33      srcs = [
    34          ":config",
    35          ":css",
    36          ":docs",
    37          ":static",
    38          ":syscallmd",
    39          "//website/blog:posts",
    40          "//website/cmd/server",
    41          "@google_root_pem//file",
    42      ],
    43      outs = ["files.tgz"],
    44      cmd = "set -x; " +
    45            "T=$$(mktemp -d); " +
    46            "mkdir -p $$T/input && " +
    47            "mkdir -p $$T/output/_site && " +
    48            "tar -xf $(location :config)    -C $$T/input && " +
    49            "tar -xf $(location :css)       -C $$T/input && " +
    50            "tar -xf $(location :docs)      -C $$T/input && " +
    51            "tar -xf $(location :syscallmd) -C $$T/input && " +
    52            "tar -xf $(location //website/blog:posts) -C $$T/input && " +
    53            "find $$T/input -type f -exec chmod u+rw {} \\; && " +
    54            "docker run -i --user $$(id -u):$$(id -g) " +
    55            "-v $$(readlink -m $$T/input):/input " +
    56            "-v $$(readlink -m $$T/output/_site):/output " +
    57            "gvisor.dev/images/jekyll && " +
    58            "tar -xf $(location :static) -C $$T/output/_site && " +
    59            "docker run -i --user $$(id -u):$$(id -g) " +
    60            "-v $$(readlink -m $$T/output/_site):/output " +
    61            "gvisor.dev/images/jekyll " +
    62            "ruby /checks.rb " +
    63            "/output && " +
    64            "cp $(location //website/cmd/server) $$T/output/server && " +
    65            "mkdir -p $$T/output/etc/ssl && " +
    66            "cp $(location @google_root_pem//file) $$T/output/etc/ssl/cert.pem && " +
    67            "tar -zcf $@ -C $$T/output . && " +
    68            "rm -rf $$T",
    69      tags = [
    70          "local",
    71          "manual",
    72          "no-sandbox",
    73      ],
    74  )
    75  
    76  # static are the purely static parts of the site. These are effectively copied
    77  # in after jekyll generates all the dynamic content.
    78  pkg_tar(
    79      name = "static",
    80      srcs = [
    81          "archive.key",
    82      ] + glob([
    83          "performance/**",
    84      ]),
    85      strip_prefix = "./",
    86  )
    87  
    88  # main.scss requires front-matter to be processed.
    89  genrule(
    90      name = "css",
    91      srcs = glob([
    92          "css/**",
    93      ]),
    94      outs = [
    95          "css.tar",
    96      ],
    97      cmd = "T=$$(mktemp -d); " +
    98            "mkdir -p $$T/css && " +
    99            "for file in $(SRCS); do " +
   100            "echo -en '---\\n---\\n' > $$T/css/$$(basename $$file) && " +
   101            "cat $$file >> $$T/css/$$(basename $$file); " +
   102            "done && " +
   103            "tar -C $$T -czf $@ . && " +
   104            "rm -rf $$T",
   105  )
   106  
   107  # config is "mostly" static content. These are parts of the site that are
   108  # present when jekyll runs, but are not dynamically generated.
   109  pkg_tar(
   110      name = "config",
   111      srcs = [
   112          ":css",
   113          "_config.yml",
   114          "//website/blog:index.html",
   115      ] + glob([
   116          "assets/**",
   117          "_includes/**",
   118          "_layouts/**",
   119          "_plugins/**",
   120          "_sass/**",
   121      ]),
   122      strip_prefix = "./",
   123  )
   124  
   125  # index is the index file.
   126  doc(
   127      name = "index",
   128      src = "index.md",
   129      layout = "base",
   130      permalink = "/",
   131  )
   132  
   133  # docs is the dynamic content of the site.
   134  docs(
   135      name = "docs",
   136      deps = [
   137          ":index",
   138          "//:code_of_conduct",
   139          "//:contributing",
   140          "//:governance",
   141          "//:security",
   142          "//g3doc:community",
   143          "//g3doc:index",
   144          "//g3doc:roadmap",
   145          "//g3doc:style",
   146          "//g3doc/architecture_guide:performance",
   147          "//g3doc/architecture_guide:platforms",
   148          "//g3doc/architecture_guide:resources",
   149          "//g3doc/architecture_guide:security",
   150          "//g3doc/proposals:gsoc_2021",
   151          "//g3doc/user_guide:FAQ",
   152          "//g3doc/user_guide:checkpoint_restore",
   153          "//g3doc/user_guide:compatibility",
   154          "//g3doc/user_guide:debugging",
   155          "//g3doc/user_guide:filesystem",
   156          "//g3doc/user_guide:install",
   157          "//g3doc/user_guide:networking",
   158          "//g3doc/user_guide:platforms",
   159          "//g3doc/user_guide/containerd:configuration",
   160          "//g3doc/user_guide/containerd:containerd_11",
   161          "//g3doc/user_guide/containerd:quick_start",
   162          "//g3doc/user_guide/quick_start:docker",
   163          "//g3doc/user_guide/quick_start:kubernetes",
   164          "//g3doc/user_guide/quick_start:oci",
   165          "//g3doc/user_guide/tutorials:cni",
   166          "//g3doc/user_guide/tutorials:docker",
   167          "//g3doc/user_guide/tutorials:docker_compose",
   168          "//g3doc/user_guide/tutorials:knative",
   169          "//g3doc/user_guide/tutorials:kubernetes",
   170      ],
   171  )
   172  
   173  # Generate JSON for system call tables
   174  genrule(
   175      name = "syscalljson",
   176      outs = ["syscalls.json"],
   177      cmd = "$(location //runsc) -- help syscalls -format json -filename $@",
   178      tools = ["//runsc"],
   179  )
   180  
   181  # Generate markdown from the json dump.
   182  genrule(
   183      name = "syscallmd",
   184      srcs = [":syscalljson"],
   185      outs = ["syscallsmd"],
   186      cmd = "T=$$(mktemp -d) && " +
   187            "$(location //website/cmd/syscalldocs) -in $< -out $$T && " +
   188            "tar -C $$T -czf $@ . && " +
   189            "rm -rf $$T",
   190      tools = ["//website/cmd/syscalldocs"],
   191  )
   192  
   193  bzl_library(
   194      name = "defs_bzl",
   195      srcs = ["defs.bzl"],
   196      visibility = ["//visibility:private"],
   197  )