blob: a6940851b28454cfeca0b3440a7cbd7d84c82041 [file] [log] [blame]
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
load("@io_bazel_rules_docker//docker/util:run.bzl", "container_run_and_commit")
load("//bazel:skia_app_container.bzl", "skia_app_container")
skia_app_container(
name = "docsyserver_container",
base_image = "@docsyserver-base//image",
dirs = {
"/usr/local/bin": [
[
"//docsyserver/go/docsyserver:docsyserver",
"0755",
],
],
"/": [
[
"//docsyserver/images:serve.sh",
"0755",
],
[
"//docsyserver/images:build.sh",
"0755",
],
],
"/usr/local/share/docsy/layouts/partials": [
[
"//docsyserver/images:head.html",
"0644",
],
[
"//docsyserver/images:page-meta-lastmod.html",
"0644",
],
],
"/usr/local/share/docsy/layouts/partials/hooks": [
[
"//docsyserver/images:head-end.html",
"0644",
],
],
"/usr/local/share/docsy/static/favicons": [
[
"//docsyserver/images:favicon.ico",
"0644",
],
],
},
entrypoint = "/usr/local/bin/docsyserver",
env = {
"PATH": "$$PATH:/home/skia/node-v14.16.0-linux-x64/bin",
},
repository = "skia-public/docsyserver",
run_commands_skia = [
# Copy artifacts over.
"cp -r /usr/local/share/docsy/layouts/partials /home/skia/docsy/layouts",
"cp -r /usr/local/share/docsy/static /home/skia/docsy",
],
)
# Builds gcr.io/skia-public/docsyserver-base, a base image for docsyserver that contains docsy and
# its dependencies. This container takes several minutes to build and rarely changes. By pinning a
# revision of this container in //WORKSPACE and using it as the base image, we can build the
# docsyserver container much faster.
container_run_and_commit(
name = "docsyserver_base_container",
commands = [
# Install golang.
"cd && wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz && tar -xzf go1.16.2.linux-amd64.tar.gz",
# Install hugo at a pinned version we know works.
"cd && git clone https://github.com/gohugoio/hugo.git && cd hugo && git checkout 803f572e66c5e22213ddcc994c41b3e80e9c1f35 " +
"&& ~/go/bin/go install --tags extended",
# Install node.
"cd && wget https://nodejs.org/dist/v14.16.0/node-v14.16.0-linux-x64.tar.gz && tar -xzf node-v14.16.0-linux-x64.tar.gz",
# Install docsy at a pinned version we know works.
"cd && git clone --recurse-submodules https://github.com/google/docsy-example.git docsy " +
"&& cd docsy && git checkout 70e301f7861122ab129d2c46ee5ed625e92c04d0",
"PATH=\"/home/skia/node-v14.16.0-linux-x64/bin:${PATH}\"",
"/home/skia/node-v14.16.0-linux-x64/bin/npm install && rm config.toml && rm -rf content",
],
docker_run_flags = [
"--user",
"skia",
],
image = ":docsyserver_base_container_root_commit.tar",
tags = [
"manual", # Exclude it from wildcard queries, e.g. "bazel build //...".
# container_run_and_commit requires the docker daemon to be running. This is not possible
# inside RBE.
"no-remote",
],
)
# Subset of the docsy dependencies that need to be installed as the root user.
container_run_and_commit(
name = "docsyserver_base_container_root",
commands = [
# Install required packages.
"apt-get update",
"apt-get install -y wget openssh-client procps unzip vim less build-essential gcc gcc-11 gcc-11-base libgcc-11-dev",
"apt-get clean",
],
docker_run_flags = [
"--user",
"root",
],
image = "@base-cipd//image",
tags = [
"manual", # Exclude it from wildcard queries, e.g. "bazel build //...".
# container_run_and_commit requires the docker daemon to be running. This is not possible
# inside RBE.
"no-remote",
],
)
# Pushes a new release of the gcr.io/skia-public/docsyserver-base container.
container_push(
name = "push_docsyserver_base_container",
format = "Docker",
image = ":docsyserver_base_container_commit.tar",
registry = "gcr.io",
repository = "skia-public/docsyserver-base",
stamp = "@io_bazel_rules_docker//stamp:always",
tag = "{STABLE_DOCKER_TAG}",
tags = [
"manual", # Exclude it from wildcard queries, e.g. "bazel build //...".
# container_push requires the docker daemon to be running. This is not possible inside RBE.
"no-remote",
],
)