如何通过Dockerfile安装`passenger-install-nginx-module`

时间:2014-12-19 11:46:00

标签: docker rvm dockerfile passenger confd

如何通过Dockerfile安装passenger-install-nginx-module

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

上面是我的dockerfile。

我只想设置passenger-nginx-module ...

但是我在Dockerfile的最后RUN指令中遇到错误

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

首先,安装乘客, 其次,尝试通过rvmsudo passenger-install-nginx-module命令安装nginx-module。

但是docker会回复此错误

错误:

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.

虽然我只是试图命令rvmsudo ...

我该怎么办?

4 个答案:

答案 0 :(得分:1)

尝试通过

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

答案 1 :(得分:0)

我确定有一种方法可以自动化配置/构建过程 - 但为什么呢?你知道passenger-install-nginx-module从源代码下载并编译nginx吗?

为什么不添加乘客apt存储库并通过apt-get安装它?这么容易。

Passenger Debian Install Guide

答案 2 :(得分:0)

user2105103说的是什么。您也可以使用passenger-docker

答案 3 :(得分:0)

试试这个 RUN passenger-install-nginx-module --auto-download --auto --prefix = / opt / nginx