2016-02-04 137 views
1

我有一個錯誤關於我的Gemfile或當我運行像這樣的一些任務捆綁:搬運工,撰寫錯誤,當我運行bundle

docker exec -it webapp_web_1 bundle exec rake db:migrate 

錯誤:無法找到的Gemfile或.bundle /目錄

或此命令:

docker-compose logs worker 

log: 
Attaching to webapp_worker_1 
worker_1 | Could not locate Gemfile or .bundle/ directory 

Dockerfile:

# === 1 === 
FROM phusion/passenger-ruby22:0.9.18 
MAINTAINER Israel Barba Aceves "[email protected]" 

# Set correct environment variables. 
ENV HOME /root 

RUN apt-get update && apt-get install -y libqt4-dev libqtwebkit-dev imagemagick 

# Use baseimage-docker's init system. 
CMD ["/sbin/my_init"] 


# === 2 === 
# Start Nginx/Passenger 
RUN rm -f /etc/service/nginx/down 

# === 3 ==== 
# Remove the default site 
RUN rm /etc/nginx/sites-enabled/default 


# Add the nginx info 
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf 

# === 4 === 
# Prepare folders 
RUN mkdir /home/app/webapp 



# === 5 === 
# Run Bundle in a cache efficient way 
WORKDIR /tmp 
ADD Gemfile /tmp/ 
ADD Gemfile.lock /tmp/ 
RUN bundle install 


#WORKDIR /webapp 
#RUN RAILS_ENV=staging rake assets:precompile --trace 

# === 6 === 
# Add the rails app 
ADD . /home/app/webapp 

RUN mkdir /home/app/webapp/tmp/cache/assets/staging 
RUN mkdir /home/app/webapp/tmp/cache/assets/staging/sprockets 
# RUN chown -R app:app /home/app/webapp/tmp/cache/assets/staging 
RUN chown -R app:app /home/app/webapp 

#RAILS_ENV=staging rake assets:precompile 


# Clean up APT when done. 
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 

泊塢窗,compose.yml

db: 
    image: postgres 
    ports: 
    - "5432" 
    volumes: 
    - ytp-postgres:/var/lib/postgresql/data 

redis: 
    image: redis 
    ports: 
    - "6379" 
    volumes: 
    - ytp-redis:/var/lib/redis/data 


web: 
    build: . 
    volumes: 
    - .:/web 
    ports: 
    - "80" 
    links: 
    - redis 
    - db 
    environment: 
    RACK_ENV: staging 
    RAILS_ENV: staging 

worker: 
    build: . 
    volumes_from: 
    - web 
    command: bundle exec sidekiq -e s -c 5 -C config/sidekiq.yml 
    environment: 
    RAILS_ENV: staging 
    links: 
    - redis 
    - db 

而且我無法從我的配置開始Sidekiq,我想這是一些關於卷,但我不知道,我已經編輯在許多方面,這文件沒有成功......任何建議?

泊塢版本: 1.9.1

泊塢窗,撰寫版本 1.6.0rc2

感謝。

+0

什麼,當你運行「泊塢窗,撰寫運行Web捆綁高管耙分貝:遷移」發生什麼呢? – TopperH

+0

同樣的錯誤:無法找到Gemfile或.bundle /目錄我必須在容器內運行遷移 –

+0

此外,sidekiq是您的項目中的寶石,是否有一個原因,你爲什麼要在一個單獨的容器中運行它?由於您的Web容器已經鏈接到Redis,我建議使用您的Web容器中的sidekiq,並使用工頭將sidekiq和rails服務器一起運行。 – TopperH

回答

2

您必須修改Dockerfile的最後一部分,以配合您的泊塢窗撰寫文件的文件夾:

WORKDIR /web 
ADD Gemfile /web/ 
ADD Gemfile.lock /web/ 
RUN bundle install 
+0

非常感謝!這是解決方案!非常簡單的東西 –

+0

@israel如果此解決方案適合您,請接受它。 – TopperH

+0

@TopperH這爲我工作,但我不能解釋它 - 你能指出我的任何文檔,以瞭解更多? – mattsch