问题描述
尝试在docker下运行Rails控制台时遇到一些问题。所有其他Rails命令都能按预期工作,但控制台不能。
➜ octopus git:(master) ✗ docker-compose run web bundle exec rails c
Creating octopus_web_run ... done
Could not find rake-13.0.6 in any of the sources
Run `bundle install` to install missing gems.
ERROR: 1
已安装RAKE。
➜ octopus git:(master) ✗ docker-compose run web bundle install
Creating octopus_web_run ... done
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.8.11
....
Bundle complete! 42 Gemfile dependencies, 144 gems now installed.
Bundled gems are installed into `./.bundle`
更多
➜ octopus git:(master) ✗ docker-compose run web bundle config list
Creating octopus_web_run ... done
Settings are listed in order of priority. The top value will be used.
app_config
Set via BUNDLE_APP_CONFIG: "/myapp/.bundle"
silence_root_warning
Set via BUNDLE_SILENCE_ROOT_WARNING: true
path
Set via BUNDLE_PATH: "/myapp/.bundle"
bin
Set via BUNDLE_BIN: "/bin"
➜ octopus git:(master) ✗ docker-compose run web bundle exec rails s -p 3000 -b '0.0.0.0'
Creating octopus_web_run ... done
=> Booting Puma
=> Rails 6.1.4.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.5.2 (ruby 2.7.5-p203) ("Zawgyi")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 1
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2022-01-17 19:28:14 +0000 ===
- Goodbye!
Exiting
和docker-compose up
照常工作。
我使用过许多类似的坞站设置,没有任何问题。我的主意快用完了。
环境设置
- 宝石在下面。/Bundle
- docker-Compose版本1.29.2
- Ruby 2.7
- Rails 6.1.4.4
文档文件
FROM ruby:2.7
RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
# Install yarn, for webpack
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs yarn
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
ENV GEM_HOME /myapp/.bundle
ENV BUNDLE_PATH=$GEM_HOME
BUNDLE_APP_CONFIG=$BUNDLE_PATH
BUNDLE_BIN=$BUNDLE_PATH/bin
ENV PATH /app/bin:$BUNDLE_BIN:$PATH
ENV NODE_OPTIONS=--openssl-legacy-provider
docker-compose.yml
version: '3.9'
services:
db:
image: postgres:13
volumes:
- octopus-db-sync:/var/lib/postgresql/data:nocopy
environment:
POSTGRES_PASSWORD: password
redis:
image: redis
web:
build: .
command: ./start_docker_development.sh
volumes:
- octopus-sync:/myapp:nocopy
environment:
BUNDLE_APP_CONFIG: /myapp/.bundle
ports:
- "3000:3000"
depends_on:
- db
- redis
- mailcatcher
nginx:
image: nginx
volumes:
- ./nginx-develop.conf:/etc/nginx/conf.d/default.conf:z
- octopus-sync:/myapp:nocopy
ports:
- "80:80"
expose:
- "80"
depends_on:
- web
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
volumes:
octopus-sync:
external: true
octopus-db-sync:
external: true
start_docker_development.sh
#!/bin/bash
bundle check || bundle install
rm -f tmp/pids/server.pid
echo > log/development.log
echo > log/test.log
bundle exec rails s -p 3000 -b '0.0.0.0'
非常感谢您的帮助。
推荐答案
我发现该问题是在Spring4.0(issue 669)中引入的。忽略捆绑包环境变量。
降级到Spring 3.1.1解决此问题。
Gemfile
gem 'spring', '~> 3.1.1'
这篇关于Docker-编写和Rails控制台问题。在任何来源中都找不到RAKE-13.0.6;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2