diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000000000..2369228816d46 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_PATH: "vendor/bundle" diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000..5381ad50b730c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!Gemfile* diff --git a/.gitignore b/.gitignore index b4038acab8641..8e19eaabb3144 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,7 @@ bin !html/sitemap.xml metastore_db html_docs/ -!resources/asciidoctor/**/bin -resources/asciidoctor/vendor/**/cache +vendor # Comes from running tests in resources/asciidoctor resources/asciidoctor/build diff --git a/Dockerfile b/Dockerfile index ca05909ce3e8e..a6799e2b9c138 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,24 +52,6 @@ RUN install_packages \ # have to be empty. So we delete them. RUN rm -rf /var/log/nginx && rm -rf /run -# Gem inventory: -# * Used by the docs build -# * asciidoctor -# * thread_safe -# * Speculative -# * asciidoctor-diagram -# * asciimath -# * Used to check the build in CI -# * rubocop -# * rspec -RUN gem install --no-document \ - asciidoctor:1.5.8 \ - asciidoctor-diagram:1.5.12 \ - asciimath:1.0.8 \ - rubocop:0.64.0 \ - rspec:3.8.0 \ - thread_safe:0.3.6 - # Wheel inventory: # * Used to test the docs build # * beautifulsoup4 @@ -79,3 +61,14 @@ RUN pip3 install \ beautifulsoup4==4.7.1 \ lxml==4.3.1 \ pycodestyle==2.5.0 + +# Install ruby deps with bundler to make things more standard for Ruby folks. +RUN gem install bundler:2.0.1 +RUN bundle config --global silence_root_warning 1 +COPY Gemfile* / +RUN bundle install --binstubs --system --frozen +# --frozen forces us to regenerate Gemfile.lock locally before using it in +# docker which is important because we need Gemfile.lock to lock the gems to a +# consistent version and we can't rely on running bundler in docker to update +# it because we can't copy from the image to the host machine while building +# the image. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000000..c402a99f5f481 --- /dev/null +++ b/Gemfile @@ -0,0 +1,18 @@ +# IMPORTANT: If you change this file you should run `bundle lock` to +# regenerate Gemfile.lock or building the docker image will fail. +source "https://rubygems.org" + +ruby "~> 2.3" + +# We commit Gemfile.lock so we're not going to have "unexpected" version bumps +# of our gems. This file specifies what we think *should* work. Gemfile.lock +# specifies what we *know* does work. +gem "asciidoctor", "~> 1.5" # Used by the docs build +gem "thread_safe", "~> 0.3.6" # Used by asciidoctor +gem "asciidoctor-diagram", "~> 1.5" # Speculative +gem "asciimath", "~> 1.0" # Speculative + +group :test do + gem "rspec", "~> 3.8" + gem "rubocop", "~> 0.64.0" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000000..1c425240a3811 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,56 @@ +GEM + remote: https://rubygems.org/ + specs: + asciidoctor (1.5.8) + asciidoctor-diagram (1.5.12) + asciidoctor (~> 1.5.0) + asciimath (1.0.8) + ast (2.4.0) + diff-lcs (1.3) + jaro_winkler (1.5.2) + parallel (1.16.2) + parser (2.6.2.0) + ast (~> 2.4.0) + powerpack (0.1.2) + rainbow (3.0.0) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) + rubocop (0.64.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.4.0) + ruby-progressbar (1.10.0) + thread_safe (0.3.6) + unicode-display_width (1.4.1) + +PLATFORMS + ruby + +DEPENDENCIES + asciidoctor (~> 1.5) + asciidoctor-diagram (~> 1.5) + asciimath (~> 1.0) + rspec (~> 3.8) + rubocop (~> 0.64.0) + thread_safe (~> 0.3.6) + +RUBY VERSION + ruby 2.5.3p105 + +BUNDLED WITH + 1.17.1 diff --git a/build_docs b/build_docs index b68440fe213b6..12f80605914a6 100755 --- a/build_docs +++ b/build_docs @@ -67,7 +67,7 @@ def build_docker_image(): else: acc.append(line) - cmd = ["docker", "image", "build", "-t", "elastic/docs_build", "-"] + cmd = ["docker", "image", "build", "-t", "elastic/docs_build", DIR] build = common_popen(cmd, dockerfile) handle_popen(build, handle_line) if build.returncode != 0: diff --git a/resources/asciidoctor/README b/resources/asciidoctor/README index 5aeb409088683..e777151b16bbd 100644 --- a/resources/asciidoctor/README +++ b/resources/asciidoctor/README @@ -1,3 +1,12 @@ These are Elastic's extensions to Asciidoctor! The `lib` directory contains the actual extensions and the spec directory contains the tests. You can run -the tests with `build_docs --self-test`. \ No newline at end of file +the tests with `build_docs --self-test` to reproduce the authoritative, in +docker tests. You can also use more ruby standard stuff like: + +``` +bundle install +bundle exec rspec +bundle exec rubocop +``` + +but it is not authoritative.