First make sure to follow the common base setup.
A Makefile provides shortcuts for interacting with the docker images.
You can see all of the targets and an explanation of what they do with:
make help
To run vets-api and its redis and postgres dependencies run the following command from within the repo you cloned in the above steps.
make up
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.
The Makefile has shortcuts for many common development tasks. You can still run manual docker-compose commands, but the following tasks have been aliased to speed development:
make spec
- Run the entire test suite via the docker image (alias forrspec spec
). Test coverage statistics are incoverage/index.html
.make guard
- Run the guard test server that reruns your tests after files are saved. Useful for TDD!
make spec_parallel_setup
- This sets up the parallel tests databases. First the existing test database is dropped and reset, then the rest of the test databases are cloned off the standard onemake spec_parallel
- Run the entire test suite in parallel. A spec folder path can optionally be given as an argument to run just the spec folder in parallel
Pending or skipped tests are ignored by default, to run the test suite with pending tests in the output, simply add the PENDING=true environment variable to the test command
PENDING=true make spec_parallel
make lint
- Run the full suite of linters on the codebase.make security
- Run the suite of security scanners on the codebase.make ci
- Run all build steps performed in CI.
make console
- Is an alias forrails console
, which runs an IRB like REPL in which all of the API's classes and environmental variables have been loaded.
To emulate a local install's workflow where you can run rspec
, rake
, or rails
commands
directly within the vets-api docker instance you can use the make bash
command.
$ make bash
Creating network "vetsapi_default" with the default driver
Creating vetsapi_postgres_1 ... done
Creating vetsapi_redis_1 ... done
# then run any command as you would locally e.g.
root@63aa89d76c17:/src/vets-api# rspec spec/requests/user_request_spec.rb:26
As a general technique, if you're running vets-api
in Docker and run into a problem, doing a make rebuild
is a good first step to fix configuration, gem, and other various code problems.
Run make build
and then try make up
again.
Could not find %SOME_GEM_v0.0.1% in any of the sources
Run `bundle install` to install missing gems.
There is no need to run bundle install
on your system to resolve this.
A rebuild of the vets_api
image will update the gems. The vets_api
docker image
installs gems when the image is built, rather than mounting them into a container when
it is run. This means that any time gems are updated in the Gemfile or Gemfile.lock,
it may be necessary to rebuild the vets_api
image using the
following command:
-
make down
- Stops all docker services. -
make rebuild
- Rebuild thevets_api
image. -
make docker-clean
- Removes all docker images and volumes associated with vets-api.