I’m moving a standard, non-dockerized, Rails app that is deployed to Heroku to Circle2.0 using the docker executor. I have very little Docker experience, so firstly, is this sensible, or should I be using the machine executor? I like the Docker approach.
I have managed to get many of the basic steps to work (installing dependencies and bundle install
) on the host machine. Then I run into trouble when I’m trying to create my database.
When running this line bundle exec rake db:create db:schema:load --trace
I get the following error:
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
FATAL: role "root" does not exist
So I seem to be connecting to the Postgres container (since there is no Postgres installed in the ruby container), but then for some reason that doesn’t appear to be configured correctly. Is my conclusion correct? In either case, suggestions would be really helpful.
This is my config.yml
so far:
version: 2
jobs:
build:
docker:
- image: ruby:2.2.2
environment:
RAILS_ENV: test
RACK_ENV: test
PG_HOST: localhost
PG_USER: ubuntu
- image: postgres:9.4.1
environment:
POSTGRES_USER: ubuntu
POSTGRES_DB: circle_ruby_test
working_directory: ~/copyin
steps:
- checkout
- run: echo "USING CIRCLE 2.0"
- run:
name: Install System Dependencies
command: apt-get update -qq && apt-get install -y build-essential nodejs
- run:
name: Install rmagick dependencies
command: apt-get install libmagickwand-dev imagemagick imagemagick-6.q16 libmagickcore-dev
- run:
name: Symlink imagemagick dependencies
command: ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
- run:
name: Install capybara-webkit dependencies
command: apt-get install --assume-yes qt5-default libqt5webkit5-dev
- run:
name: Install latest version of Bundler
command: gem install bundler
- restore_cache:
key: Gemfile-{{ checksum "Gemfile.lock" }}
- run:
name: Install Ruby Dependencies
command: bundle install
- run: bundle show rails
- save_cache:
key: Gemfile-{{ checksum "Gemfile.lock" }}
paths:
- /usr/local/bundle/gems/
- run:
name: Create DB
command: bundle exec rake db:create db:schema:load --trace
- run:
name: Run Tests
command: bundle exec rspec --drb --colour --order rand