How Can I install `passenger-install-nginx-module` via Dockerfile

1.4k Views Asked by At

How Can I install passenger-install-nginx-module via Dockerfile?

FROM ubuntu:14.04
MAINTAINER hgkim

RUN apt-get update \
    && apt-get install -y curl build-essential libpq-dev advancecomp gcc libpcre3 \
    libpcre3-dev zlib1g zlib1g-dev libssl-dev gifsicle jhead \
    jpegoptim libjpeg-progs optipng pngquant libzmq-dev libevent-dev python-dev \
    python-virtualenv python libcurl4-openssl-dev \
    && virtualenv circus && /circus/bin/pip install circus-web==0.5 \
    && ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
    && useradd -d /home/newbie -m -s /bin/bash newbie \
    && usermod -aG root newbie \
    && echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
    && curl -L -O http://sourceforge.net/projects/pmt/files/pngcrush/1.7.81/pngcrush-1.7.81.tar.gz \
    && tar xvzf pngcrush* \
    && cd pngcrush* \
    && make \
    && mv pngcrush /usr/local/bin/ \
    && cd / && curl -L https://github.com/kelseyhightower/confd/releases/download/v0.6.3/confd-0.6.3-linux-amd64 -o confd \
    && mv confd /usr/local/bin/confd && chmod +x /usr/local/bin/confd

USER newbie

RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 \
    && \curl -sSL https://get.rvm.io | bash -s stable \
    && /bin/bash -l -c "rvm install 2.1.0" \
    && /bin/bash -l -c "rvm use 2.1.0" \
    && echo "gem: --no-ri --no-rdoc" > /home/newbie/.gemrc

ENV PATH /home/newbie/.rvm/bin:/home/newbie/.rvm/gems/ruby-2.1.0/bin:/home/newbie/.rvm/gems/ruby-2.1.0@global/bin:/home/newbie/.rvm/rubies/ruby-2.1.0/bin:$PATH

RUN gem install passenger -v 4.0.55 \
    && rvmsudo passenger-install-nginx-module \
    --auto --prefix=/usr/local/nginx --auto-download --languages ruby

CMD bash

Above is my dockerfile.

I just want to setup passenger-nginx-module...

But I got error in last RUN instruction in Dockerfile

RUN gem install passenger -v 4.0.55 \
    && rvmsudo passenger-install-nginx-module \
    --auto --prefix=/usr/local/nginx --auto-download --languages ruby

First, install passenger, Second, try to install nginx-module via rvmsudo passenger-install-nginx-module command.

But docker response this error

error:

Unable to autodetect the currently active RVM gem set name. This could happen if you ran this program using 'sudo' instead of 'rvmsudo'. When using RVM, you're always supposed to use 'rvmsudo' instead of 'sudo!'.

Please try rerunning this program using 'rvmsudo'. If that doesn't help, please contact this program's author for support.

Although I just tried to command rvmsudo...

What should I do?

4

There are 4 best solutions below

0
On

What user2105103 said. You could also just use passenger-docker.

0
On

I'm sure there is a way to automate the config/build process -- but why? You know that the passenger-install-nginx-module downloads and compiles nginx from source right?

Why not just add the passenger apt repository and install it via apt-get? So much easier.

Passenger Debian Install Guide

0
On

Try this RUN passenger-install-nginx-module --auto-download --auto --prefix=/opt/nginx

0
On

try replace RUN passenger-install-nginx-module by

RUN /bin/bash -l -c 'passenger-install-nginx-module --auto-download --auto --prefix=/opt/nginx'