Skip to main content
Skip table of contents

Running the app Natively

Introduction

This doc details how to run the rails app in a native fashion (vs running via a docker based setup).

BRD

To run vets-api and its redis and postgres dependencies run the following command from within the repo you cloned in the above steps. clamav will NOT be run.

CODE
foreman start -m all=1,clamd=0,freshclam=0

EKS

Prior to EKS, ClamAV (the virus scanner) was deployed in the same process as Vets API. With EKS, ClamAV has been extracted out into it’s own service. Locally you can see the docker-compose.yml config for clamav.

TODO: Running clamav natively, as we did in Vets API master still needs to be configured. For the time being, please run via docker:

Please set the clamav intitalizer initializers/clamav.rb file to the following:

CODE
# ## If running hybrid
if Rails.env.development?
   ENV["CLAMD_TCP_HOST"] = "0.0.0.0"
   ENV["CLAMD_TCP_PORT"] = "33100"
 end
Options
Option 1: Run ONLY clamav via Docker

You can either run:
docker-compose -f docker-compose-clamav.yml up - this will run ONLY clamav via docker

After that, follow the native instructions and run foreman start -m all=1

Option 2: Run ALL dependencies via docker (Clamav, Redis, Postgres)

docker-compose -f docker-compose-deps.yml up - this will run all dependencies via docker
After that, follow the native instructions and run foreman start -m web=1 all=0

You should then be able to navigate to http://localhost:3000/v0/status in your browser and start interacting with the API. Changes to the source in your local directory will be reflected automatically via a docker volume mount, just as they would be when running rails directly.

Running tests

  • bundle exec rake spec - Run the entire test suite ( for rspec spec). Test coverage statistics are in coverage/index.html.

  • make guard - Run the guard test server that reruns your tests after files are saved. Useful for TDD!

Running tests in parallel

  • NOTE: Running specs in parallel requires that your development database exists, and is up to date. If necessary, you may need to run bundle exec rake db:create and bundle exec rake db:migrate before the following steps.

  • RAILS_ENV=test bundle exec rake parallel:setup - This prepares all of the test databases. It will create a test database for each processor on your computer.

  • RAILS_ENV=test NOCOVERAGE=true bundle exec parallel_rspec spec modules - This runs the entire test suite. Optionally, a folder path can be given as a parameter. Each file is assigned a processor, so it probably doesn't make sense to pass an individual file to run it in parallel. It is currently suggested to forgo the coverage testing by adding NOCOVERAGE=true flag (currently the coverage check will fail, even if the test suite passes). If you would like to check coverage for the test run, remove that flag.

Running linters

  • rake lint - Run the full suite of linters on the codebase and autocorrect.

  • rake security - Run the suite of security scanners on the codebase.

  • rake ci - Run all build steps performed in CI.

Running a rails interactive console

  • rails console - runs an IRB like REPL in which all of the API's classes and environmental variables have been loaded.


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.