Hi,
I have the following for my Rails app:
image: "ruby:2.6"
services:
- redis:latest
variables:
BUNDLE_CACHE: "vendor/bundle/"
LC_ALL: C.UTF-8
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_HOST: "postgresql"
POSTGRES_DB: ci
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
.default_cache: &default_cache
cache:
untracked: true
key: "gems-$CI_BUILD_REF_NAME"
paths:
- node_modules/
- vendor/bundle/
- public/
build:
<<: *default_cache
stage: build
services:
- name: mdillon/postgis:9.6
alias: postgresql
script:
- apt-get update -qq && apt-get install -y -qq nodejs postgresql-client
- ruby -v
- cp config/database.yml.example config/database.yml
- gem install bundler --no-document
- bundle config set deployment 'true'
- bundle config set path 'vendor/bundle/'
- bundle install --jobs $(nproc) "${FLAGS[@]}"
- psql -h postgresql -c "create user some_user with password '';
I’m just trying to connect to PostgreSQL, however I get the error:
psql: could not translate host name "postgresql" to address: Name or service not known
ERROR: Job failed: command terminated with exit code 1
This is with “Running with gitlab-runner 12.5.0 (577f813d) on gitlab-runner-artifact-uploader-847885b7bb-8jg6l 6EAiZtt1”.
When I run it locally with “gitlab-runner exec docker build”, it works perfectly fine.
Any hints?
Thank you
Darius