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
- How to display legend box in tooltip text for amCharts 5 in Rails application?
- how to integrate cashfree payment gateway in ruby on rails project
- RSpec Capybara throwing Selenium error when trying to click a button with browser confirm
- rails minitest not picking up fixture properly, instance variable not percolating
- Duplicate GET requests - Rails & Heroku
- How to stub out current_user in JWT model for Rspec?
- NameError in Home#index
- Verifying Google Identity OAuth2 token with Ruby
- Error WebMock::NetConnectNotAllowedError in testing with stub using minitest in rails (using Faraday)
- why is mission_control-jobs erroring with load path error?
- Rescuing validation errors from a polymorphic association
- New error on random number assigned to local variable , Rails
- How to fix error in model with gem lockbox
- Images uploaded via Active Storage not displaying in Active Admin or on certain devices
- controller test_methods generating two errors intermittently
Related Questions in POSTGRESQL
- Only the first SQL script gets executed inside Docker Postgres container
- Compare fields in two tables
- Hibernate ClobJdbcType bindings: what are the diferences?
- Postgres && statement Error in Mybatis Mapper?
- Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- How to copy data from SQLite to postgreSQL?
- PGAdmin4 configured behind a reverse proxy but unable to connect to Postgresql server
- Updates to pgsodium encrypted values don't use specified key_id
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
- Get list of matching keywords for each post
- docker-compose can't reset postgresql database
Related Questions in ELASTICSEARCH
- How does Elasticsearch do attribute filtering during knn (vector-based) retrieval?
- Elastic python to extract last 1hr tracing
- Elastic search not giving result when Hyphen is used in search text
- FluentD / Fluent-Bit: Concatenate multiple lines of log files and generate one JSON record for all key-value from each line
- Elasticsearch functional_score with parameter of type string array as input not working
- Elasticsearch - cascading http inputs from Airflow API
- AWS Opensearch - Restore snapshot - Failed to parse object: unknown field [uuid] found
- cluster block exception for system index of kibana
- What settings are best for elasticsearch query to find full word and half word
- OpenSearch - Bulk inserting Million rows from Pandas dataframe
- unable access to kibana
- PySpark elastic load fail with error SparkContext is stopping with exitCode 0
- How to use query combined to KNN with ElasticSearch?
- Facing logstash compatibility issues
- If the same document is ingested at two different times, how to have the same id in Elasticsearch
Related Questions in GITLAB-CI
- Cannot connect to Postgres Database when running Quarkus Tests with Gitlab ci
- Invalid command 'bdist_msi' when trying to create MSI installer with 'cx_Freeze' in Gitlab CI/CD Pipeline
- There are no active runners online GitLab
- On Gitlab, is there a way to allow Maintaners to merge MRs even if some checks fail?
- Gitlab pipeline stuck with nx cloud issue
- Upgrade Gitlab-runner package in amazon Linux 2 and Ubuntu 22.04 through Ansible
- How to set variables across several Earthfiles with earthly for continuous integration
- How to run particular jobs in GitLab CI/CD via GitLab API?
- How to start from a clean stage after maven release job fails in GitLab pipeline?
- How to install docker-compose on CI runner environment where you're trying to build your Docker images
- avoid duplicated job in the gitlab-ci
- How to run RedPanda Kafka container in GitLab CI for tests?
- Can't figure out why the pipeline does not run
- Migrating .gitlab-ci.yml from Terraform to OpenTofu with OIDC Setup
- how to provide custom variables in gitlab api?
Related Questions in SEARCHKICK
- Is a full reindex required after adding a new field to Opensearch mapping? (Searchkick)
- How to add multiple range filters for the same field with searchkick and elastic search?
- How to do a counting-grouping-filtering query in OpenSearch?
- What is the proper way to setup Searchkick with Minitest?
- Searchkick not retrieving results properly
- Searchkick filter by object field
- Ruby on Rails 7 - Getting a Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for 127.0.0.1:9200)
- How can I cache the results returned by searchkick in rails using low level caching?
- Need to do filter on nested field
- Searchkick::InvalidQueryError in rails 3 + Searchkick
- Is there a way to search for dates with values and empty dates in Searchkick?
- How do I iterate over indexed data in script filter query using elasticsearch?
- Is there a way to use script filelds calculation on filters using elasticsearch or opensearch API?
- Are named search queries a Searchkick feature?
- How to avoid N+1 when reindexing models with Searchkick
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 # Hahtags
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.