I have to maintain the old Ruby on Rails 2.3.17 application that works on Ruby 1.9.3 and wanted to move development to the Docker for OS X (Docker version 17.12.0-ce, build c97c6d6) but with the main goal - to have folder on the host in order to avoid reinstalling gems whenever I start new container. I tried to use Docker volume that uses host directory and install all gems there. With following Dockerfile
FROM zedtux/ruby-1.9.3
RUN apt-get update -qq \
&& apt-get install -y \
build-essential \
libmysqlclient-dev \
libxml2-dev \
libxslt-dev \
libsasl2-2 \
libsasl2-dev \
nodejs \
git \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf \
/var/lib/apt \
/var/lib/dpkg \
/var/lib/cache \
/var/lib/log
VOLUME /app
VOLUME /bundler-cache
RUN echo "---\ngem: --no-ri --no-rdoc" >> ~/.gemrc
WORKDIR /app
and docker-compose.yml
version: "3.5"
services:
web:
build: .
ports:
- "3000:3000"
volumes:
- /Users/bosko/central_bundle_storage/app-gems:/bundler-cache
- ${PWD}:/app
environment:
GEM_HOME: /bundler-cache
GEM_PATH: /bundler-cache
BUNDLE_PATH: /bundler-cache
PATH: /bundler-cache/bin:$PATH
after building and starting container with:
docker-compose run --rm web bash
I am installing bundler and gems with:
gem install bundler
bundle install
Most of gems that have to be built due to native extensions (i.e. nokogiri, etc.) install properly but I have a problem with memcached gem. Building gem fails with the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. [7/1778]
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:7: Use RbConfig instead of obsolete and deprecated Config.
Touching all files so autoconf doesn't run.
find . | xargs touch
Configuring libmemcached.
env CFLAGS='-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC -g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC' LDFLAGS='-fPIC -L. -Wl,-Bsymbolic-functions -Wl,-z,relro
-L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib
-rdynamic -Wl,-export-dynamic -L/usr/lib' ./configure --prefix=/bundler-cache/gems/memcached-1.4.6/ext --without-memcached --disable-shared --disable-utils
--disable-dependency-tracking CC="gcc" 2>&1
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock
extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.9.1
extconf.rb:35:in `run': 'env CFLAGS='-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC -g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC' LDFLAGS='-fPIC -L. -Wl,-Bsymbolic-functions -Wl,-z,relro
-L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib
-rdynamic -Wl,-export-dynamic -L/usr/lib' ./configure --prefix=/bundler-cache/gems/memcached-1.4.6/ext --without-memcached --disable-shared --disable-utils
--disable-dependency-tracking CC="gcc" 2>&1' failed (RuntimeError)
from extconf.rb:52:in `block (2 levels) in check_libmemcached'
from extconf.rb:50:in `chdir'
from extconf.rb:50:in `block in check_libmemcached'
from extconf.rb:49:in `chdir'
from extconf.rb:49:in `check_libmemcached'
from extconf.rb:69:in `<main>'
Gem files will remain installed in /bundler-cache/gems/memcached-1.4.6 for inspection.
Results logged to /bundler-cache/gems/memcached-1.4.6/ext/gem_make.out
Error is caused by following line in extconf.rb file of memcached gem:
run("env CFLAGS='-fPIC #{LIBM_CFLAGS}' LDFLAGS='-fPIC #{LIBM_LDFLAGS}' ./configure --prefix=#{HERE} --without-memcached --disable-shared --disable-utils --disable-dependency-tracking #{$CC} #{$EXTRA_CONF} 2>&1", "Configuring libmemcached.")
However if is go to /bundler-cache/gems/memcached-1.4.6/ext/libmemcached-0.32 folder while I'm still on the container's bash and execute expanded version of above command:
env CFLAGS='-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC' LDFLAGS='-fPIC -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic -L/usr/lib' ./configure --prefix=/bundler-cache/gems/memcached-1.4.6/ext --without-memcached --disable-shared --disable-utils --disable-dependency-tracking CC="gcc" 2>&1
everything goes well without any problem. Does anyone have an idea why this happens and how can it be fixed either by fixing gem installation or proper volume mounting if that is the problem?