From 440bbbb2889770e107209cb610d71af8a1913c3e Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 18 Jun 2020 14:24:41 -0500 Subject: [PATCH] Update nokogiri gem. Fix gem version conflicts described in 20abd8a5f. Nokogiri couldn't be upgraded past 1.10.9 because 1.11.0 causes a build failure in Nokogumbo 2.0.2, but we couldn't stay on 1.10.9 either because it has a hard requirement on Ruby <2.7 and we require Ruby >=2.7. This made `bundle update` fail with a Gemfile conflict. The fix is to disable libxml2 support when building Nokogumbo. Nokogumbo wants to use the same version of libxml2 as Nokogiri, but Nokogiri 1.11.0 changed how it reports which version of libxml2 it's using, which causes Nokogumbo's build to fail. Disabling libxml2 may reduce performance of Nokogumbo ([1]). While we're at it, we also make Nokogiri use the system version of libxml2 instead of its own bundled version. Nokogiri really wants us to use its own patched version of libxml2 instead of the system version, but the patches it applies look relatively minor and don't seem relevant to us ([2]). Using the system version reduces build time during CI. This adds libxml2 and libxslt as OS-level dependencies of Danbooru. You may need to do `sudo apt-get install libxml2-dev libxslt-dev` to install these libraries after this commit. [1]: https://github.com/rubys/nokogumbo#flavors-of-nokogumbo [2]: https://github.com/sparklemotion/nokogiri/tree/master/patches/libxml2 --- .bundle/config | 3 +++ .github/workflows/test.yaml | 2 +- .gitignore | 1 - Gemfile | 4 +--- Gemfile.lock | 11 +++++------ config/docker/Dockerfile.danbooru | 10 +++++++++- 6 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 .bundle/config diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 000000000..b64ad2111 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,3 @@ +--- +BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" +BUNDLE_BUILD__NOKOGUMBO: "--without-libxml2" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 53485a29a..592dac48b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -64,7 +64,7 @@ jobs: - name: Install OS dependencies run: | apt-get update - apt-get -y install --no-install-recommends build-essential ruby ruby-dev ruby-bundler git nodejs yarnpkg webpack ffmpeg mkvtoolnix libvips-dev libxml2-dev postgresql-server-dev-all wget + apt-get -y install --no-install-recommends build-essential ruby ruby-dev ruby-bundler git nodejs yarnpkg webpack ffmpeg mkvtoolnix libvips-dev libxml2-dev libxslt-dev zlib1g-dev postgresql-server-dev-all wget ln -sf /usr/bin/yarnpkg /usr/bin/yarn - name: Install Ruby dependencies diff --git a/.gitignore b/.gitignore index 8f4292733..a51a3e83b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .yarn-integrity .gitconfig .git/ -.bundle/ config/database.yml config/danbooru_local_config.rb config/deploy/*.rb diff --git a/Gemfile b/Gemfile index ad30bc238..4304f26cd 100644 --- a/Gemfile +++ b/Gemfile @@ -47,9 +47,7 @@ gem 'http' gem 'activerecord-hierarchical_query' gem 'pundit' gem 'mail' - -# locked to 1.10.9 to workaround an incompatibility with nokogumbo 2.0.2. -gem 'nokogiri', '~> 1.10.9' +gem 'nokogiri' group :production, :staging do gem 'unicorn', :platforms => :ruby diff --git a/Gemfile.lock b/Gemfile.lock index c671469e6..338a3929b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -211,7 +211,7 @@ GEM mime-types-data (3.2020.0512) mimemagic (0.3.5) mini_mime (1.0.2) - mini_portile2 (2.4.0) + mini_portile2 (2.5.0) minitest (5.14.1) minitest-ci (3.4.0) minitest (>= 5.0.6) @@ -239,10 +239,9 @@ GEM net-ssh (6.1.0) newrelic_rpm (6.11.0.365) nio4r (2.5.2) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) - nokogiri (1.10.9-x64-mingw32) - mini_portile2 (~> 2.4.0) + nokogiri (1.11.0.rc2) + mini_portile2 (~> 2.5.0) + nokogiri (1.11.0.rc2-x64-mingw32) nokogumbo (2.0.2) nokogiri (~> 1.8, >= 1.8.4) ntlm-http (0.1.1) @@ -465,7 +464,7 @@ DEPENDENCIES mock_redis net-sftp newrelic_rpm - nokogiri (~> 1.10.9) + nokogiri oauth2 pg pry-byebug diff --git a/config/docker/Dockerfile.danbooru b/config/docker/Dockerfile.danbooru index df2af68bd..013644a89 100644 --- a/config/docker/Dockerfile.danbooru +++ b/config/docker/Dockerfile.danbooru @@ -13,14 +13,20 @@ RUN \ webpack \ libvips-dev \ libxml2-dev \ + libxslt-dev \ + zlib1g-dev \ postgresql-server-dev-all && \ # webpacker expects the binary to be called `yarn`, but debian/ubuntu installs it as `yarnpkg`. ln -sf /usr/bin/yarnpkg /usr/bin/yarn WORKDIR /build +COPY .bundle .bundle COPY Gemfile Gemfile.lock ./ -RUN BUNDLE_DEPLOYMENT=true bundle install --jobs 4 +RUN \ + bundle config set deployment true --local && \ + bundle config set path vendor/bundle && \ + bundle install --jobs 4 COPY package.json yarn.lock ./ RUN yarn install @@ -44,6 +50,8 @@ RUN \ mkvtoolnix \ libvips \ libxml2 \ + libxslt1.1 \ + zlib1g \ postgresql-client USER danbooru