Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby Dockerfile with checkinstall (but checkinstall just freezes)
#!/bin/bash
set -e
mkdir -p /tmp/empty
docker build -t ruby-package -f Dockerfile.ruby /tmp/empty
# Copy deb packages from the built image to ./packages
docker run --name temp-package ruby-package /bin/true
docker cp temp-package:/packages .
docker rm temp-package
FROM debian:stretch
RUN apt-get update \
&& apt-get install -y \
curl ca-certificates \
checkinstall unzip build-essential \
automake libtool libtool-bin pkg-config \
bison \
dpkg-dev \
gcc \
libbz2-dev \
libgdbm-dev \
libglib2.0-dev \
libncurses-dev \
libreadline-dev \
libxml2-dev \
libxslt-dev \
libjemalloc-dev \
--no-install-recommends
ENV RUBY_VERSION=2.5.5 \
RUBY_MAJOR=2.5 \
RUBY_DOWNLOAD_SHA256=9bf6370aaa82c284f193264cc7ca56f202171c32367deceb3599a4f354175d7d
# Ruby with jemalloc
# Taken from https://github.com/zhulux/debian-ruby-jemalloc/blob/master/Dockerfile
# --------------------------------------------------------------------------------
WORKDIR /tmp
RUN curl -sfL "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
-o ruby.tar.xz
RUN sha256sum *ruby.tar.xz \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c -
RUN mkdir -p /usr/src/ruby
RUN tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
WORKDIR /usr/src/ruby
# Suppress "warning: Insecure world writable dir"
RUN { \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new \
&& mv file.c.new file.c
RUN autoconf
RUN GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure \
--build="$GNU_ARCH" \
--disable-install-doc \
--enable-shared \
--with-jemalloc
RUN make -j "$(nproc)"
RUN checkinstall -d2 -D -y --install=no --fstrans=no \
--nodoc --pkgversion="$RUBY_VERSION" --pakdir=/packages make install
# Sanity check for jemalloc
RUN ruby --version \
&& ruby -r rbconfig -e "RbConfig::CONFIG['LIBS'].include?('jemalloc') \
? puts('Ruby is compiled with jemalloc.') \
: raise('jemalloc is missing from Ruby!')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.