gpt4 book ai didi

ruby-on-rails - 如何使用 Dockerfile 文件运行 bundle install

转载 作者:行者123 更新时间:2023-12-04 03:43:11 24 4
gpt4 key购买 nike

我想使用 docker 来部署 Rails 应用程序。
我按照官方教程做的:

https://docs.docker.com/compose/rails/

但似乎我并不走运。

我的 Dockerfile

FROM ruby:2.2.2

RUN apt-get update -qq && apt-get install -y build-essential

# for mysql
RUN apt-get install -y mysql-client libmysqlclient-dev

# for a JS runtime
RUN apt-get install -y nodejs

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock

RUN bundle install

ADD . $APP_HOME

我的 docker-compose.yml
db:
image: mysql
ports:
- "3306:3306"
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- db

我跑后 docker-compose build , 表明:
...
Fetching git://github.com/guard/guard-test.git
/usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:94:in `[]': invalid byte sequence in US-ASCII (ArgumentError)
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:94:in `strip_leading_spaces'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:99:in `word_wrap'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:85:in `tell_me'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:31:in `error'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:12:in `rescue in with_friendly_errors'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:7:in `with_friendly_errors'
from /usr/local/bundle/gems/bundler-1.10.6/bin/bundle:18:in `<top (required)>'
from /usr/local/bundle/bin/bundle:23:in `load'
from /usr/local/bundle/bin/bundle:23:in `<main>'
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 1

怎么了?

最佳答案

查看“bundle install error “invalid byte sequence in US-ASCII (ArgumentError)” ”中的类似错误,一种选择是将广告添加到 Dockerfile:

export LANG=C.UTF-8

this Dockerfile例如。
# Install required packages
# LANG=C.UTF-8 line is needed for ondrej/php5 repository
RUN \
export LANG=C.UTF-8 && \
...

关于ruby-on-rails - 如何使用 Dockerfile 文件运行 bundle install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33559075/

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