ruby-on-rails - Docker:bash:bundle:找不到命令
问题描述
我正在尝试对我的 Rails 6 应用程序进行 Dockerize 化,但似乎遇到了最后一个障碍。运行时docker-compose up
一切正常,直到我在控制台中进入“附加到 rdd-ruby_db_1,rdd-ruby_web_1”,然后我得到错误bash: bundle: command not found
。
我知道 Stackoverflow 上针对同一问题的其他答案,但在发布此问题之前我已经尝试了所有方法。
我的 Dockerfile:
FROM ruby:2.7
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN cd /usr/bin/
RUN bundle install
FROM node:6.7.0
RUN npm install -g yarn
COPY . /myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
我的码头工人撰写
version: '3'
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: xxx
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
我最初遵循 Docker 文档中的指南,认为这可以在https://docs.docker.com/compose/rails/
谢谢。
解决方案
推荐阅读
- excel - VBA 代码在非英语系统中不起作用
- android - MapBox - PropertyFactory.iconImage() 带有在 MapBox Studio 上上传的自定义图标?
- swiftui - 延迟动画而不是使用计时器
- java - 我收到一个错误,导致我的应用程序崩溃
- angular - angular-8 中的 node-sass 漏洞问题
- python - 在 PySimpleGUI 中更新值
- python - Django-rest-framework :创建序列化程序,以使用一个自定义用户模型注册两种不同的用户类型外键关系
- android-studio - 将图像保存在图库中时如何修复错误?
- scala - 如何避免使用 Scala 类型为通用 Spark RDD 重载方法?
- javascript - 如何使用单个事件侦听器而不是每个按钮中的 onclick 事件来做一个迷你计算器?