2017-02-25 14 views
1

ドッカーの作成(ドッカーのバージョン1.12.5、ビルド7392c3b /ドッカーの作成1.9.0、ビルド2585387)を使用して、かなり標準的なレール(5.0.1)プロジェクトを持っています。環境。残念なことに、Railsがすべてのリロード時にクラスをリロードする通常の開発モードは機能していないようです。代わりに、私のコーディングのサイクルとなっています:コンテナを再構築して再起動する必要があります。ブラウザからリロードできない

  1. ^C docker-compose up
  2. docker-compose build
  3. docker-compose up
  4. のうち泡、すすぎ、私はいくつかのサービスは、すべての時間を実行しているので

を繰り返し私はdocker-compose upのうちCを強制して、世界を再構築して再起動すると時間がかかり、私のPostgres(データベース)インスタンスを 頭。

ビューファイルを変更して変更をすぐに確認できるので、アプリケーションのマウントが正常に機能していることは明らかです。しかし、クラスをに変更すると、私は強制的にキャンセル - コンパイル - 再開のダンスをします。

ドッキングウィンドウ-compose.yml

services: 
    app: 
    env_file: 
    - .env 
    depends_on: 
    - database 
    - redis 
    build: 
     context: . 
     args: 
     - environment 
    command: bin/rails server --port 3000 --binding 0.0.0.0 
    environment: 
     REDIS_URL: "redis://redis:6379/0" 
    links: 
    - database 
    - redis 
    network_mode: bridge 
    ports: 
    - "3000:3000" 
    expose: 
    - 3000 
    volumes: 
    - .:/app:rw 

Dockerfile

# https://hub.docker.com/_/ruby/ 
FROM ruby:2.3-slim 

# Install apt based dependencies required to run Rails as 
# well as RubyGems. As the Ruby image itself is based on a 
# Debian image, we use apt-get to install those. 
# nodejs for JavaScript runtime 
RUN apt-get update -qq && \ 
    apt-get install -y --no-install-recommends build-essential libpq-dev nodejs git && \ 
    rm -rf /var/lib/apt/lists/* && \ 
    echo "linux up-to-date" 

# Configure the main working directory. This is the base 
# directory used in any further RUN, COPY, and ENTRYPOINT 
# commands. 
RUN mkdir /app 
WORKDIR /app 

# build args, provided --build-arg 
ARG environment=production 
ARG GIT_COMMIT=unknown 
ARG VERSION=unknown 

# May be overridden by docker-compose.yml 
ENV RAILS_ENV=$environment RACK_ENV=$environment NODE_ENV=$environment 

# Copy the Gemfile as well as the Gemfile.lock and install 
# the RubyGems. This is a separate step so the dependencies 
# will be cached unless changes to one of those two files 
# are made. 
COPY Gemfile Gemfile.lock ./ 
RUN gem install bundler && bundle install --jobs 20 --retry 5 

# Copy the main application. 
COPY . ./ 

# Precompile Rails assets 
RUN bundle exec rake assets:precompile 

# Start console (starting puma creates a .pid file that we don't want) 
CMD bundle exec rails console 

答えて

-1

はあなたのドッカー構成ファイルにrestart: alwaysを追加して、デーモンとして実行したいと思うでしょう行くdocker compose up -d。これはビルド後もフォアグラウンドを実行しないデーモンとして実行されます。また、マシンを再起動すると、コンテナが再起動されます。依存関係についてもrestart=alwaysを設定して、リブート時に起動させる必要があることに注意してください。最後に、アプリケーションをボリュームとしてマウントし、コードを変更してdocker restart appを介してサイクルするようにします。ファイルをDockerコンテナにコピーすると、そのたびに再構築する必要があるため、スナップショットが作成されます。これを解決するには、コードディレクトリをボリュームとしてマウントし、コンパイルコマンドを「スタートCMD」に設定して、再起動時にビルドを実行するようにします。

0

遅れて回答しましたが、これをdevelopment.rbに設定すると問題が解決されました。

config.reload_classes_only_on_change = false

それはVirtualBoxのファイルのタイムスタンプとRailsリロード機能間の問題です示唆している、https://github.com/rails/rails/issues/16678とは何かを持っているかもしれません。

+0

おそらくこれも、https://github.com/rails/rails/issues/16678#issuecomment-113058925 –

関連する問題