Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add minimal container for building docs #92

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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)$
46 changes: 46 additions & 0 deletions build_container/Dockerfile-docs
Original file line number Diff line number Diff line change
@@ -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"]
23 changes: 23 additions & 0 deletions build_container/build-docs.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions build_container/build_container_docs.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions build_container/docs-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

chown envoydev /docs
rm -rf /docs/*

exec gosu envoydev "${@}"