How does one go about configuring a .gitlab-ci.yml file for a Rails app that depends on PosgreSQL and Elasticsearch via the searchkick gem to run my tests when I push it to GitLab?
GitLab CI for Rails App Using Postgres and Elasticsearch (searchkick gem)
737 Views Asked by Jake Anderson At
1
There are 1 best solutions below
Related Questions in RUBY-ON-RAILS
- Rails HABTM: Select everything a that a record 'has'
- Best way to make an HABTM association via console
- dynamically create an ical / ics file from a rails model
- Ruby destroy is not working? Or objects still present?
- NoMethodError: undefined method `update_average_rating' for nil:NilClass
- Select results where joined table contains records with an attribute, but without another
- Showing posts only created when boolean was true
- Ruby on rails and HAML - Print a hash with background color
- How can I monitor an endpoint's status with Ruby?
- How to create dynamic pages without form_for helper in Rails?
- Rails 4.2 jQuery loads only after refresh
- "Access Denied" - User's Permissions to S3 Bucket
- ActiveRecord, Rails 4: has_many :through with scoped conditions failure
- Rails - formatting a list of options
- Rails - Ajax do not work properly on production server
Related Questions in POSTGRESQL
- Why does adding a JOIN completely modify the query planner behaviour?
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Aggregate and count in PostgreSQL
- Rails HABTM: Select everything a that a record 'has'
- Trigger using data from inserted row
- Select results where joined table contains records with an attribute, but without another
- DB candidate as CouchDB/Schema replacement
- How do I properly add data in SQLAlchemy?
- Postgres in Conda Environment (Ubuntu 14.04)
- How to customize the output of the Postgres Pseudo Encrypt function?
- Split a large query (2 days) into pieces to increase the speed in Postgres
- Why does pg_search prefix not work like I expect?
- extracting meta info from a table psql using information_schema
- How to query a table in the database and copy it's data into one one?
- Update a table using info from a second table and a condition from a third table in Postgresql
Related Questions in ELASTICSEARCH
- Elasticsearch schema for multiple versions of the same text
- Elasticsearch nested filter query
- Elasticsearch data model
- search with filter by token count
- Usage of - operator in elasticsearch
- Running multiprocessing on two different functions in Python 2.7
- How to get an Elasticsearch aggregation with multiple fields
- How to implement custom sort in elasticsearch?
- Custom Analyzer not working Elasticsearch
- How to implement full text search using Elasticsearch in Rails?
- UnresolvedAddressException in Logstash+elasticsearch
- Elasticsearch Fiddler No DNS
- Monolithic ETL to distributed/scalable solution and OLAP cube to Elasticsearch/Solr
- how to disable page query in Spring-data-elasticsearch
- Create Custom Analyzer after index has been created
Related Questions in GITLAB-CI
- Adding A Certificate Authority in GitLab?
- GitLab & GitLab CI WebHook Error
- How do you rsync build files from Gitlab CI to another server
- Laravel application CI with Docker & Gitlab
- Schedule or trigger jobs in gitlab-ci
- GitlabCI run docker review app
- send mail to commiter after gitlab CI stage
- GitLab CI ssh registry login
- How to cache in gitlab-ci
- committing to repository as part of CI build
- Npm install doesn't succeed in Gitlab Continuous Integration
- Install Docker in container for use by GitLab CI build
- Unknown Command - LFTP
- Proper way of automatically adding indexes docker service with Gitlab CI
- Herkoku Node Deployment with Subfolder
Related Questions in SEARCHKICK
- Building a dynamic SearchKick query throws syntax error
- returning the score with searchkick
- Searchkick, typeahead.js and Elasticsearch issues
- ElasticSearch / Searchkick - LIKE query
- Twitter Typeahed 0.11.1 only showing one result
- Rails Searchkick / Elasticsearch has_many and belongs_to associations
- How to make Searchkick return what was passed on the search box plus what was chosen in the dropdown?
- Searchkick on Heroku is not working
- Searchkick without stemming
- Search statistics on Searchkick
- ElasticSearch indices become empty randomly
- Multiple where clauses in rails searchkick
- URI::InvalidURIError: the scheme http does not accept registry part: :9200 (or bad hostname?)
- Fetching results in random order with a :where clause using searchkick and rails
- Searchkick with aws elasticsearch
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I wanted to post this question, as it took me far too long to find the answer and don't want others to feel my pain. The below example not only builds my application, but also runs all my specs.
Setup
Configuration
Add the following files to your Rails app with the configurations listed.
config/gitlab-database.yml
.gitlab-ci.yml
And that's it! You're now configured to auto-run your specs on gitlab for each push.
Further Explaination
Let's start with PostgreSQL. When we start our new runner, the application we're copying in won't know how to properly connect to Postgres. Thus we create a new
database.ymlfile, which we prefixed withgitlab-so it doesn't conflict with our actual configuration, and copy that file into runner's config directory. Thecpcommand not only copy's the file, but will replace the file if it currently exists.The items we're connecting to via GitLab are
database:,user:, andpassword:. We do this by specifying those same names within our environmentvariables, ensuring everything connects properly.Okay, connecting to PostgreSQL is well explained and documented on GitLab's website. So how did I get Elasticsearch working, which isn't explained very well anywhere?
The magic happens again in
variables. We needed to set theELASTICSEARCH_URLenvironmental variable, made available to us through the Searchkick gem, as Elasticsearch looks forhttp://localhost:9200by default. But since we're using Elasticsearch through a service, we need to explicitly tell it to not use the default and use our service's hostname. So we then replacedhttp://localhost:9200withhttp://elasticsearch:9200, which does map properly to our service.