Trying to run a rails mysql app, but keep getting the following error:
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
If I ssh into the box I cannot even access the mysql service:
sudo service mysql status
mysql: unrecognized service
Here is my config.yml, I am clearly including the mysql image, and all env vars I found when reading similar forum posts.
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.3-node-browsers
environment:
BUNDLE_PATH: vendor/bundle
RAILS_ENV: test
- image: circleci/mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: AmazonMWS_test
MYSQL_ROOT_HOST: 127.0.0.1
MYSQL_USER: root
working_directory: ~/AmazonMWS
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Bundle Install
command: bundle check || bundle install
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# Database setup
- run:
name: Wait for DB
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
- run:
name: Database setup
command: bin/rails db:schema:load --trace
# run tests!
- run:
name: Run rspec in parallel
command: |
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results