0

I am pretty new in padrino so I have been struggling with this for a while and it is really blocking me.

What I am trying to do is, to dokerize my padrino project in order to make it available to my front end co-workers so they don't need to spend to much time setting their machines up.

The problem comes when I try to run the docker-compose run web bundle exec rake sq:create task which raises the the following exception:

=> Creating database 'my_database_dev'
rake aborted!
Errno::ENOENT: No such file or directory - createdb
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sql-helpers.rb:18:in `spawn'
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sql-helpers.rb:18:in `create_db'
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sequel.rb:52:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:

That exception only happens on my docker machine, even using DATABASE_URL=postgres://pg_pass:pg_user@postgres.local:2345/my_database_dev which correspond to the dockerized postgres image in my local .env file everything runs as expected, so that makes me think that the issue is that something is missing in Dockerfile.

My Dockerfile looks like this:

FROM ruby:2.2.5
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app

and my docker-compose file

version: '2'
services:
db:
  image: postgres:latest
  ports:
    - "2345:5432"
  environment:
    - POSTGRES_PASSWORD=pg_pass
    - POSTGRES_USER=pg_user
web:
  build: .
  command: bundle exec padrino s -p 3000 -h '0.0.0.0'
  ports:
    - "3000:3000"
  volumes:
    - .:/app
  depends_on:
    - db
  links:
    - db:db
  environment:
    - DATABASE_URL=postgres://pg_pass:pg_user@postgres.local:2345/my_database_dev

Thank you in advance!

1 Answers1

3

I encountered the very same problem just a couple of hours ago. This error, Errno::ENOENT: No such file or directory - createdb, indicates that your web container can't locate createdb, a script provided by Postgres. To solve this, add postgresql-client to your Dockerfile

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client

re-build your web container

docker-compose build web

and re-run the db creation & migration

docker-compose run web bundle exec rake sq:create
docker-compose run web bundle exec rake sq:migrate
crn
  • 323
  • 1
  • 2
  • 8