Fatal error when running rake db:create

When my ci script gets to the part where it attempts to create the database it aborts because the command is being run as root. Is it really necessary for me to create a user just to run those commands that should not be run as root?

Abridged output:

cp config/database.yml.ci config/database.yml bundle exec rake db:create RAILS_ENV=test
*** Mocha deprecation warning: Change require 'mocha' to require 'mocha/setup'.
FATAL: role “root” does not exist

gitlab-ci.yml

image: ruby:1.9
services:

  • postgres

variables:
POSTGRES_DB: results_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: “”
before_script:

  • whoami
  • apt-get -y update
  • apt-get -y install nodejs
  • gem install bundler --no-ri --no-rdoc
    rspec:
    script:
    • bundle install --jobs $(nproc) --path=/cache/bundler
    • cp config/database.yml.ci config/database.yml
    • bundle exec rake db:create RAILS_ENV=test
    • bundle exec rspec
      tags:
    • ruby
    • postgres
    • docker

database.yml

test:
adapter: postgresql
encoding: utf8
database: results_test
pool: 5
host: postgres
user: runner
password: “”