当我运行像这样的任务时,我的gemfile或包有错误:
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 "israel@yotepresto.com"
# 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,我想这是卷的内容,但我不确定,我已经在很多方面编辑了这个文件而没有成功......有什么建议吗?
Docker版本: 1.9.1
Docker-compose版本 1.6.0rc2
感谢。
答案 0 :(得分:2)
您必须修改Dockerfile的最后一部分以匹配docker compose文件的文件夹:
WORKDIR /web
ADD Gemfile /web/
ADD Gemfile.lock /web/
RUN bundle install