Description
Environment
Operating System
Please describe your operating system and version here.
If unsure please try the following from the command line:
Linux 4124334e150d 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 18.04
TinyTDS Version and Information
tiny_tds (2.1.2)
FreeTDS Version
freetds-1.00.92
Description
I am building a Rails application with a multi-stage Docker build. My Dockerfile looks something like this, although we have a base image that isn't quite ubuntu 18.04 that adds some Oracle libraries we need, Passenger, and sets up nginx to run as a non-root user:
# Build free tds and put it somewhere easy to get to
FROM ubuntu:18.04 as tds_builder
RUN apt-get update && apt-get install -y wget gcc make && \
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.92.tar.gz && \
tar -xzf freetds-1.00.92.tar.gz && \
cd freetds-1.00.92 && \
./configure --prefix=/home/deploy/tds && \
make && make install && make clean
# Build all our gems
FROM ubuntu:18.04 as builder
ENV PATH="${PATH}:/home/.gem/bin"
COPY --from=tds_builder /home/deploy/tds/lib /usr/local/lib
COPY --from=tds_builder /home/deploy/tds/include/* /usr/local/include/
COPY --from=tds_builder /home/deploy/tds/etc/* /etc/freetds/
RUN apt-get update && apt-get install -y curl links g++ git ruby-dev zlib1g-dev make && \
chown deploy:www-data /var/www
USER deploy
RUN mkdir /var/www/app && \
git clone <ruby-app-git-url> --depth=1 --branch stable --single-branch /var/www/app && \
cd /var/www/app && \
gem install rake --no-document --no-ri && \
gem install bundler --no-document --no-ri &&\
bundle install --without development test
# Set up final container
FROM ubuntu:18.04 as final
ENV PATH="${PATH}:${ORACLE_BASE}:/home/.gem/bin"
COPY --from=builder --chown=deploy:www-data /home/.gem /home/.gem
COPY --from=builder --chown=deploy:www-data /var/www/app /var/www/app
COPY --from=builder --chown=deploy:www-data /etc/default/nginx /etc/default/nginx
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/include/* /usr/local/include/
COPY --from=builder /etc/freetds /etc/freetds
EXPOSE 8080
ENTRYPOINT [ "start.sh" ]
We have several applications we do this with, but the ones using TinyTDS encounter the following error: Error: The application encountered the following error: libsybdb.so.5: cannot open shared object file: No such file or directory - /home/.gem/gems/tiny_tds-2.1.2/lib/tiny_tds/tiny_tds.so (LoadError)
It seems like TinyTDS relies on something outside of the gem directory, and in addition to the free tds lib/include files when it builds its native extension that gets lost in the copy. None of the other gems we include have had this problem since we use this builder pattern successfully with our other apps.
If I add make and gcc to the final container and do a gem install tiny_tds
everything starts to work again so there's definitely something extra being built that I'm not finding. Any advice?