Hi All,
I am trying to build a pipeline configuration. But facing issues related to mysql connectivity.
I get the following error:
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/run/mysqld/
Below is my bitbucket-pipelines.yml
image: ruby:2.5
pipelines:
default:
- step:
caches:
- bundler
- yarn
services:
- mysql
script:
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get update && apt-get install -y nodejs apt-transport-https
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update
- apt-get install -y xvfb yarn qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
- yarn install
- export DATABASE_URL=mysql2://root:mysql@localhost/rspec_db
- cp config/database.ci.yml config/database.yml
- bundle install --path vendor
- RAILS_ENV=test bundle exec rake db:test:prepare
- xvfb-run -a bundle exec rspec
definitions:
caches:
bundler: ./vendor
yarn: ./node_modules
services:
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: 'rspec_db'
MYSQL_ROOT_PASSWORD: 'mysql'
Please find database.yml for reference
default: &default
adapter: mysql2
encoding: utf8mb4
username: root
password: mysql
port: 3306
host: 127.0.0.1
development:
<<: *default
database: rspec_db
test:
<<: *default
database: rspec_db