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
64 lines
1.4 KiB
Docker
64 lines
1.4 KiB
Docker
FROM ubuntu:20.04 AS build
|
|
|
|
RUN \
|
|
apt-get update && \
|
|
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
|
build-essential \
|
|
ruby \
|
|
ruby-dev \
|
|
ruby-bundler \
|
|
git \
|
|
nodejs \
|
|
yarnpkg \
|
|
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 config set deployment true --local && \
|
|
bundle config set path vendor/bundle && \
|
|
bundle install --jobs 4
|
|
|
|
COPY package.json yarn.lock ./
|
|
RUN yarn install
|
|
|
|
COPY . .
|
|
|
|
ARG DATABASE_URL=postgresql://0.0.0.0
|
|
ARG DANBOORU_SECRET_KEY_BASE=1234
|
|
ARG RAILS_ENV=production
|
|
RUN bin/rails assets:precompile && ln -sf packs public/packs-test
|
|
RUN rm -rf node_modules log tmp && mkdir log tmp
|
|
|
|
FROM ubuntu:20.04
|
|
|
|
RUN \
|
|
useradd --create-home --user-group danbooru && \
|
|
apt-get update && \
|
|
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
|
ruby \
|
|
ffmpeg \
|
|
mkvtoolnix \
|
|
libvips \
|
|
libxml2 \
|
|
libxslt1.1 \
|
|
zlib1g \
|
|
postgresql-client
|
|
|
|
USER danbooru
|
|
WORKDIR /home/danbooru/app
|
|
COPY --from=build --chown=danbooru /build .
|
|
|
|
VOLUME ["/home/danbooru/app/public/data"]
|
|
ENTRYPOINT ["./bin/rails"]
|
|
CMD ["server"]
|