2016-02-04 136 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