Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .buildkite/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export GIT_AUTHOR_EMAIL='[email protected]'
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL


build_args=""
rebuild_opt=""
broken_links_opt=""
Expand Down Expand Up @@ -38,7 +37,8 @@ ssh-keyscan github.com >> "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/id_rsa"

ssh-agent bash -c "
ssh-add &&
ssh-add &&
eval \"\$(rbenv init -)\" &&
./build_docs --all \
--target_repo [email protected]:elastic/built-docs \
--reference /opt/git-mirrors/ \
Expand Down
8 changes: 7 additions & 1 deletion .buildkite/scripts/build_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,20 @@ build_cmd="./build_docs --all \
echo "The following build command will be used"
echo $build_cmd

diag_cmd="echo \"which ruby -> \$(which ruby)\" && \
echo \"which asciidoctor -> \$(which asciidoctor)\" && \
echo \"ruby -v -> \$(ruby -v || echo 'ruby not found')\" && \
echo \"asciidoctor --version -> \$(asciidoctor --version || echo 'asciidoctor not found')\" && \
echo \"GEM_PATH is: \$GEM_PATH\""

# Temporary workaround until we can move to HTTPS auth
vault read -field=private-key secret/ci/elastic-docs/elasticmachine-ssh-key > "$HOME/.ssh/id_rsa"
vault read -field=public-key secret/ci/elastic-docs/elasticmachine-ssh-key > "$HOME/.ssh/id_rsa.pub"
ssh-keyscan github.com >> "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/id_rsa"

# Kick off the build
ssh-agent bash -c "ssh-add && $build_cmd"
ssh-agent bash -c "ssh-add && eval \"\$(rbenv init -)\" && eval \"\$(export RBENV_ROOT /root/.rbenv)\" && eval \"\$(export PATH \$RBENV_ROOT/bin:\$RBENV_ROOT/shims:\$PATH)\" && eval \"\$(export GEM_PATH /var/lib/gems:/usr/local/bin:\$GEM_PATH)\" && $diag_cmd && $build_cmd"

buildkite-agent annotate \
--style "success" \
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -euo pipefail

export GEM_PATH=/var/lib/gems${GEM_PATH:+:$GEM_PATH}

echo "Building images for docs test"
for IMAGE in build py_test node_test ruby_test integ_test diff_tool; do
echo Building $IMAGE
Expand Down
11 changes: 11 additions & 0 deletions .docker/ruby_openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -986,7 +986,9 @@
rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);

DefRSAConst(PKCS1_PADDING);
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
DefRSAConst(SSLV23_PADDING);
+#endif
DefRSAConst(NO_PADDING);
DefRSAConst(PKCS1_OAEP_PADDING);
47 changes: 39 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Debian builds the docs about 20% faster than alpine. The image is larger
# and takes longer to build but that is worth it.
FROM bitnami/minideb:buster AS base
FROM bitnami/minideb:bookworm AS base

# TODO install_packages calls apt-get update and then nukes the list files after. We should avoid multiple calls to apt-get update.....
# We could probably fix this by running the update and installs ourself with `RUN --mount type=cache` but that is "experimental"
Expand All @@ -18,9 +18,9 @@ COPY .docker/apt/keys/nodesource.gpg /
RUN apt-key add /nodesource.gpg
COPY .docker/apt/sources.list.d/nodesource.list /etc/apt/sources.list.d/
RUN install_packages \
build-essential python2 \
build-essential python-is-python3 \
# needed for compiling native modules on ARM
nodejs ruby \
nodejs rbenv ruby-build \
# Used both to install dependencies and at run time
bash less \
# Just in case you have to shell into the image
Expand All @@ -32,22 +32,47 @@ RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV RBENV_ROOT /root/.rbenv
ENV PATH $RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH
ENV GEM_PATH /var/lib/gems:/usr/local/bin:$GEM_PATH
RUN rbenv init -


FROM base AS ruby_deps
ENV RUBY_VERSION 2.5.8
RUN eval "$(rbenv init -)"

RUN install_packages \
bundler \
# ruby-build bundler \
# Fetches ruby dependencies
ruby-dev make cmake gcc libc-dev patch
# ruby-dev \
make cmake gcc libc-dev patch \
# Required to compile some of the native dependencies
libssl-dev libnss-wrapper

ENV RUBY_CFLAGS="-O3 -fno-fast-math -g3 -Wall -Wno-error=deprecated-declarations"
RUN ls
COPY .docker/ruby_openssl.patch /tmp/
RUN rbenv install $RUBY_VERSION --patch < /tmp/ruby_openssl.patch || (cat /tmp/ruby-build.*.log && exit 1) && \
rbenv global $RUBY_VERSION && \
gem install bundler -v 1.17.3 --no-document && \
rbenv rehash

ENV RUBY_CFLAGS=""

RUN bundle config --global silence_root_warning 1
COPY Gemfile* /
# --frozen forces us to regenerate Gemfile.lock locally before using it in
# docker which lets us lock the versions in place.
RUN bundle install --binstubs --system --frozen --without test
COPY .docker/asciidoctor_2_0_10.patch /
RUN cd /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10 && patch -p1 < /asciidoctor_2_0_10.patch
RUN cd $RBENV_ROOT/versions/$RUBY_VERSION/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10 && \
patch -p1 < /asciidoctor_2_0_10.patch

RUN mkdir -p /var/lib/gems && \
cp -R $RBENV_ROOT/versions/$RUBY_VERSION/lib/ruby/gems/* /var/lib/gems/ && \
cp $RBENV_ROOT/versions/$RUBY_VERSION/bin/* /usr/local/bin/
RUN find /usr/local/bin -type f -exec sed -i '1s|#!.*/bin/ruby|#!/usr/bin/env ruby|' {} +

FROM base AS node_deps
COPY .docker/apt/keys/yarn.gpg /
Expand All @@ -59,13 +84,17 @@ COPY yarn.lock /
ENV YARN_CACHE_FOLDER=/tmp/.yarn-cache
# --frozen-lockfile forces us to regenerate yarn.lock locally before using it
# in docker which lets us lock the versions in place.
RUN yarn global add node-gyp
RUN yarn install --frozen-lockfile --production


# This is the image we use to build the docs. We build on it in other
# Dockerfiles to make the images to serve previews and air gapped docs.
FROM base AS build
LABEL MAINTAINERS="Nik Everett <[email protected]>"

COPY --from=ruby_deps /root/.rbenv /root/.rbenv

RUN install_packages \
git \
# Clone source repositories and commit to destination repositories
Expand Down Expand Up @@ -103,9 +132,9 @@ RUN rm -rf /var/log/nginx && rm -rf /run/nginx
FROM base AS py_test
# There's not a published wheel for yamale, so we need setuptools and wheel
RUN install_packages python3 python3-pip python3-setuptools python3-wheel python3-dev libxml2-dev libxslt-dev zlib1g-dev
RUN pip3 install \
RUN pip3 install --break-system-packages \
beautifulsoup4==4.8.1 \
lxml==4.4.2 \
lxml==4.9.4 \
pycodestyle==2.5.0 \
yamale==3.0.1 \
pyyaml==5.3.1
Expand All @@ -117,10 +146,12 @@ FROM ruby_deps AS ruby_test
RUN bundle install --binstubs --system --frozen --with test

FROM build AS integ_test
COPY --from=ruby_test /root/.rbenv /root/.rbenv
COPY --from=node_test /node_modules /node_modules
COPY --from=ruby_test /var/lib/gems /var/lib/gems
COPY --from=ruby_test /usr/local/bin/rspec /usr/local/bin/rspec
COPY --from=ruby_test /usr/local/bin/rubocop /usr/local/bin/rubocop
COPY --from=ruby_test /usr/local/bin/asciidoctor /usr/local/bin/asciidoctor

FROM py_test AS diff_tool
RUN install_packages git
2 changes: 1 addition & 1 deletion Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
!.docker
!Gemfile*
!package.json
!yarn.lock
!yarn.lock
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DEPENDENCIES
thread_safe (~> 0.3.6)

RUBY VERSION
ruby 2.5.3p105
ruby 2.5.8

BUNDLED WITH
1.17.3
2 changes: 1 addition & 1 deletion build_docs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ sub init_env {
chomp($gid);
print $override "docker:x:$uid:$gid:docker:/tmp:/bin/bash\n";
close $override;
$ENV{LD_PRELOAD} = '/usr/lib/libnss_wrapper.so';
$ENV{LD_PRELOAD} = 'libnss_wrapper.so';
$ENV{NSS_WRAPPER_PASSWD} = '/tmp/passwd';
$ENV{NSS_WRAPPER_GROUP} = '/etc/group';
}
Expand Down