Bitbucket Pipeline: Can't find postgres service

DW
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2018

I'm having a hard time getting my bitbucket-pipelines.yml to work. It keeps getting stuck on rake db:migrate with the error: PG::ConnectionBad: could not translate host name "db" to address: Name or service not known

 

I see the service running though, with no errors. I am at a loss why it's not working. Here is my configuration so far:

image: ruby:2.5
clone:
depth: full
pipelines:
default:
- step:
script:
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get update
- apt-get install nodejs -y
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.5.1
- export PATH=$HOME/.yarn/bin:$PATH
- yarn
- bundle install
- rake db:migrate
- rake db:test:prepare
- rake test
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
services:
- db

definitions:
services:
db:
image: postgres
environment:
POSTGRES_DB: app_test

1 answer

1 vote
DW
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2018

Ended up fixing this by making a pipeline specific database.yml file and overwriting the original in the pipeline. In the pipeline specific yml I have it look for postgres on localhost with port 5432.

I thought that the pipeline configuration would work like docker-compose but that is not the case apparently.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events