ruby on rails - Issue with docker and bundler -
i'm running issues docker/docker-compose , bundler. after building image can run rails server
correctly without issue, but, when try run console rails console
get:
could not find i18n-0.7.0 in of sources run `bundle install` install missing gems.
if try run bundle install
in container there no problem, seems correctly installed.
docker-compose run web bundle install
... using spring 1.3.6 using therubyracer 0.12.2 using turbolinks 2.5.3 using uglifier 2.7.2 using web-console 2.2.1 updating files in vendor/cache bundle complete! 24 gemfile dependencies, 119 gems installed. bundled gems installed /usr/local/bundle.
my docker-compose.yml
looks this:
db: image: postgres web: build: . command: rails s -p 3000 -b 0.0.0.0 ports: - "3000:3000" volumes: - .:/app - ./github_rsa:/root/.ssh/id_rsa links: - db
i need mount volume ssh key because there gems need pulled private repositories.
my dockerfile
looks this:
from ruby:2.2.0 run apt-get update -qq && apt-get install -y build-essential \ libpq-dev \ libxml2-dev libxslt1-dev \ nodejs env home /root env app_home /app run mkdir $app_home run mkdir $app_home/tmp run mkdir $app_home/log # copy gemfile , gemfile.lock image. # temporarily set working directory are. workdir /tmp add gemfile gemfile add gemfile.lock gemfile.lock # copy github key pulling gems copy github_rsa /root/.ssh/id_rsa run \ chown -r root:root /root/.ssh && \ chmod 700 $home/.ssh && \ chmod 600 $home/.ssh/id_rsa run echo "host github.com\n\tstricthostkeychecking no\n" >> /root/.ssh/config # start ssh agent , add keys run eval "$(ssh-agent)" && \ ssh-add && \ ssh-add -l # install bundler run gem install bundler -v '~> 1.10' # install ruby dependencies run bundle install # remove ssh key now, don't want ship secrets on our images run rm /root/.ssh/id_rsa # add app container add . $app_home # add container working directory workdir $app_home # expose puma port expose 3000
you need take image down immediately. following not work:
run rm /root/.ssh/id_rsa
you cannot remove files this; still exist in previous layers , accessible has image. @ moment, are shipping secrets.
regarding actual question, suspect it's working directory , paths. try moving run bundle install
after workdir
instruction.
Comments
Post a Comment