diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..93c8b5a2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +# https://travis-ci.org/#!/phlax/envoy-docs + +dist: bionic + +script: + - export COMPOSE_FILE=./composition/docker-compose.yml + - docker build -f build_container/Dockerfile-docs -t phlax/envoy-build build_container + - docker images + +before_deploy: + - echo $DOCKER_ACCESS_TOKEN | docker login -u phlax --password-stdin + +deploy: + provider: script + script: docker push phlax/envoy-build + skip_cleanup: true + on: + all_branches: true + condition: $TRAVIS_BRANCH =~ ^(master)$ diff --git a/build_container/Dockerfile-docs b/build_container/Dockerfile-docs new file mode 100644 index 00000000..7662eab7 --- /dev/null +++ b/build_container/Dockerfile-docs @@ -0,0 +1,46 @@ +ARG BUILD_FROM=debian:buster-slim +FROM $BUILD_FROM +ENV DEBIAN_FRONTEND=noninteractive \ + ENVOY_SRCDIR=/source/envoy +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + curl \ + git \ + gosu \ + ninja-build \ + python-pip \ + python3-pip \ + rsync \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ + && pip3 install -U virtualenv \ + && useradd \ + -m \ + -d /home/envoydev \ + -k /etc/skel \ + -s /bin/bash \ + envoydev \ + && mkdir -p /source /docs \ + && chown envoydev:envoydev /source /docs +COPY ./docs-entrypoint.sh ./build-docs.sh /usr/local/bin/ + +COPY ./build_container_docs.sh / +RUN ./build_container_docs.sh \ + && rm /build_container_docs.sh + +# warm the bazel and pip caches +USER envoydev +RUN cd /source/ \ + && git clone https://github.com/envoyproxy/envoy \ + && cd envoy \ + && pip3 install -U pip setuptools \ + && pip3 install -r docs/requirements.txt \ + && ./docs/build.sh \ + && cd \ + && rm -rf /source/envoy +USER root + +ENTRYPOINT ["docs-entrypoint.sh"] +CMD ["build-docs.sh"] diff --git a/build_container/build-docs.sh b/build_container/build-docs.sh new file mode 100755 index 00000000..0d9ba2bf --- /dev/null +++ b/build_container/build-docs.sh @@ -0,0 +1,23 @@ +#!/bin/bash -e + +export ENVOY_REPO=(${ENVOY_REPO:-https://github.com/envoyproxy/envoy}) + +fetch_repo () { + if [ -d "$ENVOY_SRCDIR" ]; then + echo "Building docs from mounted source" + elif [ -n "${ENVOY_REPO}" ]; then + echo "Building docs from clone: ${ENVOY_REPO[@]}" + mkdir -p $(dirname "$ENVOY_SRCDIR") + cd $(dirname "$ENVOY_SRCDIR") + git clone "${ENVOY_REPO[@]}" + fi + if [ ! -d "$ENVOY_SRCDIR" ]; then + echo "Either mount an envoy source dir to /source/envoy or set ENVOY_REPO to a valid envoy repository" + exit 1 + fi +} + +fetch_repo +cd "$ENVOY_SRCDIR" +./docs/build.sh +cp -a generated/docs/* /docs diff --git a/build_container/build_container_docs.sh b/build_container/build_container_docs.sh new file mode 100755 index 00000000..38f16455 --- /dev/null +++ b/build_container/build_container_docs.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +function download_and_check () { + local to=$1 + local url=$2 + local sha256=$3 + + curl -fsSL --output "${to}" "${url}" + echo "${sha256} ${to}" | sha256sum --check +} + + +# buildifier +VERSION=2.2.1 +download_and_check /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/"$VERSION"/buildifier \ + 731a6a9bf8fca8a00a165cd5b3fbac9907a7cf422ec9c2f206b0a76c0a7e3d62 +chmod +x /usr/local/bin/buildifier + +# buildozer +VERSION=2.2.1 +download_and_check /usr/local/bin/buildozer https://github.com/bazelbuild/buildtools/releases/download/"$VERSION"/buildozer \ + 5aa4f70f5f04599da2bb5b7e6a46af3e323a3a744c11d7802517d956909633ae +chmod +x /usr/local/bin/buildozer + +# bazelisk +VERSION=1.3.0 +download_and_check /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v${VERSION}/bazelisk-linux-amd64 \ + 98af93c6781156ff3dd36fa06ba6b6c0a529595abb02c569c99763203f3964cc +chmod +x /usr/local/bin/bazel diff --git a/build_container/docs-entrypoint.sh b/build_container/docs-entrypoint.sh new file mode 100755 index 00000000..832e3f50 --- /dev/null +++ b/build_container/docs-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +chown envoydev /docs +rm -rf /docs/* + +exec gosu envoydev "${@}"