gpt4 book ai didi

ruby-on-rails - 捆绑程序安装的 gem 无法持久保存在无花果/docker 中

转载 作者:行者123 更新时间:2023-12-02 19:43:53 24 4
gpt4 key购买 nike

我正在尝试使用无花果和 docker 为现有的Rails应用程序设置本地开发环境。

在构建过程中,我清楚地看到 bundle 程序正在安装应用程序的gems,但是当我尝试使用fig up启动容器或什至使用/ bin / bash命令重新打开它时,gem是不可见的。

这是Dockerfile:

FROM ubuntu:14.04

# REPOS
RUN apt-get -qq update
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
RUN add-apt-repository -y ppa:chris-lea/node.js
RUN apt-get -y update

#INSTALL
RUN apt-get install -y -q build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison pkg-config libpq-dev make wget unzip git vim nano nodejs gawk libgdbm-dev libffi-dev

#RUBY
RUN mkdir -p /download
WORKDIR download
RUN wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
RUN tar xvfz ruby-2.1.2.tar.gz

WORKDIR /download/ruby-2.1.2

RUN ./configure
RUN make
RUN make install
RUN gem update --system
RUN gem install bundler
RUN mkdir /rent
WORKDIR /rent
ADD Gemfile /rent/Gemfile
ADD Gemfile.lock /rent/Gemfile.lock
RUN bundle install --deployment

这是fig.yml文件:
web:
build: .
command: bundle exec rails s -p 3000
volumes:
- .:/rent
ports:
- "3000:3000"

运行 fig build可以清楚地显示该应用程序正在安装的gem。
运行 fig up失败,并显示以下消息

bundler: command not found: rails



如果我运行 fig run web /bin/bash并检查其中的内容

/local/lib/ruby/gems/2.1.0/gems



它仅安装了bundler,rdoc,rake和其他一些工具。

如果我导航到该应用程序的目录并运行 bundle命令,它将安装该应用程序的gem,并且可以看到它们已安装在上面的目录中。我什至可以使用 rails server启动该应用程序。

为什么 bundle 的 gem 没有保留在图像中(容器?)。

我在无花果网站上运行过rails tutuorial,但没有这个问题。

谢谢

最佳答案

看来问题是由--deploymentbundle install标志一起使用引起的。

该标志的主要作用是将gem部署到vendor / bundle /目录,而不是常规的gem位置。我检查了一下,发现 gem 在那里,所以我不确定为什么 ruby 找不到它们。

无论如何,删除--deployment可以解决此问题。

关于ruby-on-rails - 捆绑程序安装的 gem 无法持久保存在无花果/docker 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24226836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com