Setting up CD for a Ruby on Rails project with Bitbucket Pipelines and Docker Setting up CD for a Ruby on Rails project with Bitbucket Pipelines and Docker docker docker

Setting up CD for a Ruby on Rails project with Bitbucket Pipelines and Docker


Taking the advice from https://bitbucket.org/spittet/ruby-postgresql you could easily setup your bitbucket-pipelines.yml like this:

image: spittet/ruby-postgresqlpipelines:  default:    - step:        script:          - bundle install          - /etc/init.d/postgresql start          - sudo -u postgres sh -c 'createuser root --createdb'          - rails db:setup RAILS_ENV=test          - rspec

As you may see I needed to create a user with permissions for creating databases.

For debugging you could try locally first:

run -i -t -v <local_directory_of_your_rails_app>:<directory_on_docker> spittet/ruby-postgresql /bin/bashcd <directory_on_docker>bundle install...


Docker compose is still not available inside Bitbucket Pipelines, so you'll have to use a single Docker image which has all the dependencies you need already installed.

We've also struggled with finding good Docker container with Django Postgres stack and ended up building custom Docker container. I've described the whole process and steps in a post: Building, Testing and Deploying Django App with Bitbucket Pipelines. You can use it as a template for your project, and replace Python dependencies with Ruby.