Skip to content

Commit

Permalink
site/build: Allow building without docs
Browse files Browse the repository at this point in the history
with this change, you can build the site with no docs:

```console
export BAZEL_BUILD_OPTIONS="--//site:no_docs_archive=True --//site:no_docs_latest=True"
docker compose run build
```

Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax committed Dec 11, 2024
1 parent b4bf038 commit b7d6d03
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
15 changes: 8 additions & 7 deletions build-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ debug_jvm_fail () {

inject_ci_bazelrc () {
{

PROC_COUNT="$(nproc)"
PROCS=$((PROC_COUNT - 1))
SPHINX_ARGS="-j 12 -v warn"
echo "build:ci --action_env=SPHINX_RUNNER_ARGS=\"${SPHINX_ARGS}\""
# echo "build:ci --local_ram_resources=20480"

} > repo.bazelrc

cat repo.bazelrc
}


Expand All @@ -43,15 +39,20 @@ if [[ -e "$OUTPUT_DIR" ]]; then
fi

mkdir -p "${OUTPUT_DIR}"
BAZEL_BUILD_ARGS=()

if [[ -n "$BAZEL_BUILD_OPTIONS" ]]; then
read -ra BAZEL_BUILD_OPTIONS <<< $BAZEL_BUILD_OPTIONS
else
BAZEL_BUILD_OPTIONS=()
fi

if [[ -n "$CI" ]]; then
BAZEL_BUILD_ARGS=(--config=ci)
BAZEL_BUILD_OPTIONS+=(--config=ci)
inject_ci_bazelrc
fi

$BAZEL run \
"${BAZEL_BUILD_ARGS[@]}" \
"${BAZEL_BUILD_OPTIONS[@]}" \
--@envoy//tools/tarball:target=//site \
@envoy//tools/tarball:unpack \
"$OUTPUT_DIR" || debug_jvm_fail
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ services:
- ~/.cache/bazelisk:/$HOME/.cache/bazelisk
working_dir: /src/workspace/envoy-website
environment:
BAZEL_BUILD_OPTIONS: $BAZEL_BUILD_OPTIONS
LOCAL_UID: ${UID:?"`UID` must be set, try `export UID`"}
LOCAL_USER_NAME: $USERNAME
LOCAL_USER_HOME: $HOME
Expand Down
31 changes: 29 additions & 2 deletions site/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@envoy_toolshed//website:macros.bzl", "static_website")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

Expand Down Expand Up @@ -36,20 +37,46 @@ label_flag(
visibility = ["//visibility:public"],
)

bool_flag(
name = "no_docs_archive",
build_setting_default = False,
)

config_setting(
name = "disable_docs_archive",
flag_values = {":no_docs_archive": "True"},
)

label_flag(
name = "docs_latest",
build_setting_default = ":docs",
visibility = ["//visibility:public"],
)

bool_flag(
name = "no_docs_latest",
build_setting_default = False,
)

config_setting(
name = "disable_docs_latest",
flag_values = {":no_docs_latest": "True"},
)

static_website(
name = "site",
srcs = [":docs_archive"],
srcs = select({
":disable_docs_archive": [],
"//conditions:default": [":docs_archive"],
}),
compressor = "@envoy//tools/zstd",
compressor_args = "-T0",
content = "//site/content",
data = "//site/data",
extension = "tar.zst",
theme = "//site/theme",
deps = [":docs_latest"],
deps = select({
":disable_docs_latest": [],
"//conditions:default": [":docs_latest"],
}),
)

0 comments on commit b7d6d03

Please sign in to comment.