docker中的Rails 5.1应用:捆绑安装失败在迷你赛车手处
我有一个在Mac上本地运行的Rails应用程序,并且无法将其部署到Docker容器。 Dockerfile运行时没有问题,直到说明
RUN bundle install --deployment --without development test
我遇到的错误是
Installing mini_racer 0.6.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r
./siteconf20220512-6-jda14.rb extconf.rb
checking for -lpthread... yes
creating Makefile
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
make "DESTDIR=" clean
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
make "DESTDIR="
compiling mini_racer_extension.cc
cc1plus: warning: command-line option ‘-Wimplicit-int’ is valid for C/ObjC but
not for C++
...
cc1plus: note: unrecognized command-line option ‘-Wno-constant-logical-operand’
may have been intended to silence earlier diagnostics
linking shared-object mini_racer_extension.so
g++: error:
/usr/local/bundle/gems/libv8-node-16.10.0.0-x86_64-linux/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a:
No such file or directory
make: *** [Makefile:262: mini_racer_extension.so] Error 1
make failed, exit code 2
我使用的是Rails 5.2.7,Ruby,2.6.10,Bundler版本1.17。我以IS Ruby开头的Docker映像:2.6
。 (是一个旧的项目。)
我发现 https:// https:// github.com/rubyjs/mini_racer/issues/218 ,但是那里的解决方法对我无济于事。我尝试在gemfile.lock中的“ code> platforms ”部分中添加x86_64-linux
,将其代替Platforms
entry> entry> entry ruby
完全删除gemfile.lock。如我所见,小型录音机的安装过程对我的图像有故障,Afaik运行了Ubuntu。
由于容器构建失败,因此永远不会设置,因此不可能进行手动校正。是否可以指定微型录音机版本(我当前锁定为0.6.2)以避免问题?还是还有其他解决方案?
I have got a Rails app that runs locally on my Mac and I am unable to deploy it to a Docker container. The Dockerfile runs without problem up to the statement
RUN bundle install --deployment --without development test
The error I get is
Installing mini_racer 0.6.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r
./siteconf20220512-6-jda14.rb extconf.rb
checking for -lpthread... yes
creating Makefile
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
make "DESTDIR=" clean
current directory:
/usr/local/bundle/gems/mini_racer-0.6.2/ext/mini_racer_extension
make "DESTDIR="
compiling mini_racer_extension.cc
cc1plus: warning: command-line option ‘-Wimplicit-int’ is valid for C/ObjC but
not for C++
...
cc1plus: note: unrecognized command-line option ‘-Wno-constant-logical-operand’
may have been intended to silence earlier diagnostics
linking shared-object mini_racer_extension.so
g++: error:
/usr/local/bundle/gems/libv8-node-16.10.0.0-x86_64-linux/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a:
No such file or directory
make: *** [Makefile:262: mini_racer_extension.so] Error 1
make failed, exit code 2
I am using Rails 5.2.7, Ruby, 2.6.10, Bundler version 1.17. The Docker image I start with is ruby:2.6
. (It is an old project.)
I have found https://github.com/rubyjs/mini_racer/issues/218, but the workarounds there don't help me. I have tried adding x86_64-linux
in the section PLATFORMS
in Gemfile.lock, substituting it for the PLATFORMS
entry ruby
and removing Gemfile.lock altogether. As I see it, the installation process for mini-racer is faulty for my image, which AFAIK runs Ubuntu.
As the container build fails, so it never gets set up, a manual correction afterwards is not possible. Is it possible to specify a mini-racer version (I am currently locked at 0.6.2) to avoid the problem? Or is there any other solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了。我要做的第一件事是评论
运行捆绑bundle install ...
以及dockerfile中的所有以下命令(因为这是事情开始出错的一点),但entry> entrypoint 。但是我更换了Docker-Entrypoint脚本的内容。我没有尝试启动乘客,而是插入了
tail -f/dev/null
,它永远不会终止。然后,我将行
tty:true
添加到我的docker-compose.yml
文件中,在失败的容器部分中。 (Afaiu这将在等于Docker Exec -t
的容器中创建一个终端。然后,Docker-Compose成功了,并且容器保持启动和运行。
这使得使用
docker exec -it ... bash
进入运行容器成为可能,因此直接在运行容器中调试我的配置。事实证明,我所需要的只是gem'mini_racer',< 0.5.0',平台::我的gemfile中的ruby
。我希望这个详细的答案对别人有所帮助。
I figured it out. The first thing I did was to comment out
RUN bundle install...
and all following commands in the Dockerfile (since this was the point where things started going wrong) exceptENTRYPOINT
. But I replaced the contents of my docker-entrypoint script. Instead of trying to start passenger, I insertedtail -f /dev/null
, which never terminates.Then I added a line
tty:true
to mydocker-compose.yml
file in the section of the container that failed. (AFAIU this creates a terminal into the container equivalent todocker exec -t
).Then docker-compose succeeded and the container stayed up and running.
This made it possible to enter the running container using
docker exec -it ... bash
and so debug my configuration directly in the running container. It turned out that all I needed wasgem 'mini_racer', '< 0.5.0', platforms: :ruby
in my Gemfile.I hope this detailed answer helps someone else.